-
Notifications
You must be signed in to change notification settings - Fork 9
Two Go rules 10Oct2024 #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,31 @@ | ||
id: missing-ssl-minversion-go | ||
language: go | ||
severity: warning | ||
message: >- | ||
MinVersion` is missing from this TLS configuration. By default, TLS | ||
1.2 is currently used as the minimum when acting as a client, and TLS 1.0 | ||
when acting as a server. General purpose web applications should default | ||
to TLS 1.3 with all other protocols disabled. Only where it is known that | ||
a web server must support legacy clients with unsupported an insecure | ||
browsers (such as Internet Explorer 10), it may be necessary to enable TLS | ||
1.0 to provide support. Add `MinVersion: tls.VersionTLS13' to the TLS | ||
configuration to bump the minimum version to TLS 1.3. | ||
note: >- | ||
[CWE-327]: Use of a Broken or Risky Cryptographic Algorithm | ||
[OWASP A03:2017]: Sensitive Data Exposure | ||
[OWASP A02:2021]: Cryptographic Failures | ||
[REFERENCES] | ||
https://owasp.org/Top10/A02_2021-Cryptographic_Failures | ||
utils: | ||
match_tls_without_minversion: | ||
kind: composite_literal | ||
pattern: $R | ||
inside: | ||
stopBy: end | ||
kind: assignment_statement | ||
rule: | ||
any: | ||
- matches: match_tls_without_minversion | ||
constraints: | ||
R: | ||
regex: ^(tls.Config) |
This file contains hidden or 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,17 @@ | ||
id: ssl-v3-is-insecure-go | ||
language: go | ||
severity: warning | ||
message: >- | ||
SSLv3 is insecure because it has known vulnerabilities. Starting with | ||
go1.14, SSLv3 will be removed. Instead, use 'tls.VersionTLS13'. | ||
note: >- | ||
[CWE-327]: Use of a Broken or Risky Cryptographic Algorithm | ||
[OWASP A03:2017]: Sensitive Data Exposure | ||
[OWASP A02:2021]: Cryptographic Failures | ||
[REFERENCES] | ||
https://golang.org/doc/go1.14#crypto/tls | ||
https://www.us-cert.gov/ncas/alerts/TA14-290A | ||
rule: | ||
kind: composite_literal | ||
all: | ||
- pattern: "tls.Config{$$$, MinVersion: tls.VersionSSL30, $$$}" | ||
13 changes: 13 additions & 0 deletions
13
tests/__snapshots__/missing-ssl-minversion-go-snapshot.yml
This file contains hidden or 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,13 @@ | ||
id: missing-ssl-minversion-go | ||
snapshots: | ||
? | | ||
server.TLS = &tls.Config{ Rand: zeroSource{}, } | ||
: labels: | ||
- source: 'tls.Config{ Rand: zeroSource{}, }' | ||
style: primary | ||
start: 14 | ||
end: 47 | ||
- source: 'server.TLS = &tls.Config{ Rand: zeroSource{}, }' | ||
style: secondary | ||
start: 0 | ||
end: 47 |
This file contains hidden or 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,25 @@ | ||
id: ssl-v3-is-insecure-go | ||
snapshots: | ||
? | | ||
client := &http.Client{ | ||
Transport: &http.Transport{ | ||
// ruleid: ssl-v3-is-insecure | ||
TLSClientConfig: &tls.Config{ | ||
KeyLogWriter: w, | ||
MinVersion: tls.VersionSSL30, | ||
Rand: zeroSource{}, // for reproducible output; don't do this. | ||
InsecureSkipVerify: true, // test server certificate is not trusted. | ||
}, | ||
}, | ||
} | ||
: labels: | ||
- source: |- | ||
tls.Config{ | ||
KeyLogWriter: w, | ||
MinVersion: tls.VersionSSL30, | ||
Rand: zeroSource{}, // for reproducible output; don't do this. | ||
InsecureSkipVerify: true, // test server certificate is not trusted. | ||
} | ||
style: primary | ||
start: 107 | ||
end: 358 |
This file contains hidden or 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,13 @@ | ||
id: missing-ssl-minversion-go | ||
valid: | ||
- | | ||
TLSClientConfig: &tls.Config{ | ||
KeyLogWriter: w, | ||
MinVersion: tls.VersionSSL30, | ||
Rand: zeroSource{}, | ||
InsecureSkipVerify: true, | ||
}, | ||
|
||
invalid: | ||
- | | ||
server.TLS = &tls.Config{ Rand: zeroSource{}, } |
This file contains hidden or 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,28 @@ | ||
id: ssl-v3-is-insecure-go | ||
valid: | ||
- | | ||
client_good := &http.Client{ | ||
Transport: &http.Transport{ | ||
TLSClientConfig: &tls.Config{ | ||
KeyLogWriter: w, | ||
// OK | ||
MinVersion: tls.VersionTLS10, | ||
Rand: zeroSource{}, // for reproducible output; don't do this. | ||
InsecureSkipVerify: true, // test server certificate is not trusted. | ||
}, | ||
}, | ||
} | ||
|
||
invalid: | ||
- | | ||
client := &http.Client{ | ||
Transport: &http.Transport{ | ||
// ruleid: ssl-v3-is-insecure | ||
TLSClientConfig: &tls.Config{ | ||
KeyLogWriter: w, | ||
MinVersion: tls.VersionSSL30, | ||
Rand: zeroSource{}, // for reproducible output; don't do this. | ||
InsecureSkipVerify: true, // test server certificate is not trusted. | ||
}, | ||
}, | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.