-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add semgrep github action * Add custom semgrep rules for sensu-go * Fix nil context issues found by semgrep Signed-off-by: Eric Chlebek <[email protected]>
- Loading branch information
Showing
17 changed files
with
195 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Semgrep | ||
on: [pull_request] | ||
jobs: | ||
semgrep: | ||
runs-on: ubuntu-latest | ||
name: Check | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: Semgrep | ||
id: semgrep | ||
uses: returntocorp/semgrep-action@v1 | ||
with: | ||
config: p/dgryski.semgrep-go | ||
semgrep-sensu: # looks for .semgrep.yml due to missing config section | ||
runs-on: ubuntu-latest | ||
name: Check | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- name: SemgrepSensu | ||
id: semgrep-sensu | ||
uses: returntocorp/semgrep-action@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
rules: | ||
- id: resolveparams-passed-nil-context | ||
patterns: | ||
- pattern: | | ||
$FUNC(..., graphql.ResolveParams{...}, ...) | ||
- pattern-not-inside: | | ||
$FUNC(..., graphql.ResolveParams{..., Context: $X, ...,}, ...) | ||
message: graphql.ResolveParams literal with nil context passed to function | ||
languages: [go] | ||
severity: ERROR | ||
- id: resolveparams-nil-context-var | ||
patterns: | ||
- pattern: var $X graphql.ResolveParams | ||
- pattern-not-inside: | | ||
var $X graphql.ResolveParams | ||
... | ||
$X.Context = $Y | ||
message: graphql.ResolveParams created with nil context | ||
languages: [go] | ||
severity: ERROR | ||
- id: resolveparams-nil-context-var-2 | ||
patterns: | ||
- pattern: $X := graphql.ResolveParams{} | ||
- pattern-not-inside: | | ||
$X := graphql.ResolveParams{} | ||
... | ||
$X.Context = $Y | ||
message: graphql.ResolveParams created with nil context | ||
languages: [go] | ||
severity: ERROR | ||
- id: params-passed-nil-context | ||
patterns: | ||
- pattern: | | ||
$FUNC(..., graphql.Params{...}, ...) | ||
- pattern-not-inside: | | ||
$FUNC(..., graphql.Params{..., Context: $X, ...,}, ...) | ||
message: graphql.Params literal with nil context passed to function | ||
languages: [go] | ||
severity: ERROR | ||
- id: params-nil-context-var | ||
patterns: | ||
- pattern: var $X graphql.Params | ||
- pattern-not-inside: | | ||
var $X graphql.Params | ||
... | ||
$X.Context = $Y | ||
message: graphql.Params created with nil context | ||
languages: [go] | ||
severity: ERROR | ||
- id: params-nil-context-var-2 | ||
patterns: | ||
- pattern: $X := graphql.Params{} | ||
- pattern-not-inside: | | ||
$X := graphql.Params{} | ||
... | ||
$X.Context = $Y | ||
message: graphql.Params created with nil context | ||
languages: [go] | ||
severity: ERROR | ||
- id: relay-params-passed-nil-context | ||
patterns: | ||
- pattern: | | ||
$FUNC(..., NodeResolverParams{...}, ...) | ||
- pattern-not-inside: | | ||
$FUNC(..., NodeResolverParams{..., Context: $X, ...,}, ...) | ||
message: NodeResolverParams literal with nil context passed to function | ||
languages: [go] | ||
severity: ERROR | ||
- id: relay-params-nil-context-var | ||
patterns: | ||
- pattern: var $X NodeResolverParams | ||
- pattern-not-inside: | | ||
var $X NodeResolverParams | ||
... | ||
$X.Context = $Y | ||
message: NodeResolverParams created with nil context | ||
languages: [go] | ||
severity: ERROR | ||
- id: relay-params-nil-context-var-2 | ||
patterns: | ||
- pattern: $X := NodeResolverParams{} | ||
- pattern-not-inside: | | ||
$X := NodeResolverParams{} | ||
... | ||
$X.Context = $Y | ||
message: NodeResolverParams created with nil context | ||
languages: [go] | ||
severity: ERROR | ||
- id: generic-resolver-params-nil-context | ||
patterns: | ||
- pattern-regex: .*ResolverParams\{\} | ||
message: ResolverParams created with nil context | ||
languages: [go] | ||
severity: ERROR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.