-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: support go versioned imports * fix: allow identifier patterns to match package names * fix: better guess for go package names * fix: also strip go- prefix from packages * fix: lookup index operand variables * fix: handle another import case
- Loading branch information
Showing
6 changed files
with
222 additions
and
4 deletions.
There are no files selected for viewing
142 changes: 142 additions & 0 deletions
142
internal/languages/golang/.snapshots/TestImport--main.yml
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,142 @@ | ||
high: | ||
- rule: | ||
cwe_ids: | ||
- "42" | ||
id: import_test | ||
title: Test imports | ||
description: Test imports | ||
documentation_url: "" | ||
line_number: 13 | ||
full_filename: main.go | ||
filename: main.go | ||
source: | ||
location: | ||
start: 13 | ||
end: 13 | ||
column: | ||
start: 2 | ||
end: 10 | ||
sink: | ||
location: | ||
start: 13 | ||
end: 13 | ||
column: | ||
start: 2 | ||
end: 10 | ||
content: "" | ||
parent_line_number: 13 | ||
fingerprint: 7cec89718a2276537c30e7b656c0ecb2_0 | ||
old_fingerprint: 7cec89718a2276537c30e7b656c0ecb2_0 | ||
- rule: | ||
cwe_ids: | ||
- "42" | ||
id: import_test | ||
title: Test imports | ||
description: Test imports | ||
documentation_url: "" | ||
line_number: 14 | ||
full_filename: main.go | ||
filename: main.go | ||
source: | ||
location: | ||
start: 14 | ||
end: 14 | ||
column: | ||
start: 2 | ||
end: 10 | ||
sink: | ||
location: | ||
start: 14 | ||
end: 14 | ||
column: | ||
start: 2 | ||
end: 10 | ||
content: "" | ||
parent_line_number: 14 | ||
fingerprint: 7cec89718a2276537c30e7b656c0ecb2_1 | ||
old_fingerprint: 7cec89718a2276537c30e7b656c0ecb2_1 | ||
- rule: | ||
cwe_ids: | ||
- "42" | ||
id: import_test | ||
title: Test imports | ||
description: Test imports | ||
documentation_url: "" | ||
line_number: 15 | ||
full_filename: main.go | ||
filename: main.go | ||
source: | ||
location: | ||
start: 15 | ||
end: 15 | ||
column: | ||
start: 2 | ||
end: 10 | ||
sink: | ||
location: | ||
start: 15 | ||
end: 15 | ||
column: | ||
start: 2 | ||
end: 10 | ||
content: "" | ||
parent_line_number: 15 | ||
fingerprint: 7cec89718a2276537c30e7b656c0ecb2_2 | ||
old_fingerprint: 7cec89718a2276537c30e7b656c0ecb2_2 | ||
- rule: | ||
cwe_ids: | ||
- "42" | ||
id: import_test | ||
title: Test imports | ||
description: Test imports | ||
documentation_url: "" | ||
line_number: 16 | ||
full_filename: main.go | ||
filename: main.go | ||
source: | ||
location: | ||
start: 16 | ||
end: 16 | ||
column: | ||
start: 2 | ||
end: 10 | ||
sink: | ||
location: | ||
start: 16 | ||
end: 16 | ||
column: | ||
start: 2 | ||
end: 10 | ||
content: "" | ||
parent_line_number: 16 | ||
fingerprint: 7cec89718a2276537c30e7b656c0ecb2_3 | ||
old_fingerprint: 7cec89718a2276537c30e7b656c0ecb2_3 | ||
- rule: | ||
cwe_ids: | ||
- "42" | ||
id: import_test | ||
title: Test imports | ||
description: Test imports | ||
documentation_url: "" | ||
line_number: 17 | ||
full_filename: main.go | ||
filename: main.go | ||
source: | ||
location: | ||
start: 17 | ||
end: 17 | ||
column: | ||
start: 2 | ||
end: 10 | ||
sink: | ||
location: | ||
start: 17 | ||
end: 17 | ||
column: | ||
start: 2 | ||
end: 10 | ||
content: "" | ||
parent_line_number: 17 | ||
fingerprint: 7cec89718a2276537c30e7b656c0ecb2_4 | ||
old_fingerprint: 7cec89718a2276537c30e7b656c0ecb2_4 | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package main | ||
|
||
import ( | ||
"example.com/a/v5" | ||
"example.com/b" | ||
"example.com/c-go.v5" | ||
"example.com/go-d" | ||
|
||
e "example.com/foo" | ||
) | ||
|
||
func m() { | ||
a.Test() | ||
b.Test() | ||
c.Test() | ||
d.Test() | ||
e.Test() | ||
other.Test() | ||
} |
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 @@ | ||
languages: | ||
- go | ||
patterns: | ||
- pattern: $<PACKAGE>.Test() | ||
filters: | ||
- variable: PACKAGE | ||
detection: import_test_package | ||
scope: cursor | ||
auxiliary: | ||
- id: import_test_package | ||
patterns: | ||
- import ($<!>"example.com/a/v5") | ||
- import ($<!>"example.com/b") | ||
- import ($<!>"example.com/c-go.v5") | ||
- import ($<!>"example.com/go-d") | ||
- import ($<!>"example.com/foo") | ||
severity: high | ||
metadata: | ||
description: Test imports | ||
remediation_message: Test imports | ||
cwe_id: | ||
- 42 | ||
id: import_test |