-
Notifications
You must be signed in to change notification settings - Fork 34
SONARTEXT-819 Create rule S6418: Secrets should not be hard-coded #5940
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
7 commits
Select commit
Hold shift + click to select a range
59f497a
Add secrets to rule S6418
daniel-teuchert-sonarsource afafe63
Add first draft
daniel-teuchert-sonarsource c012849
Merge branch 'master' into rule/S6418-add-secrets
daniel-teuchert-sonarsource 6a9d37f
Improve description
daniel-teuchert-sonarsource 234e41f
Minor clean up
daniel-teuchert-sonarsource 8715241
Add sentence to distinguish S6418 from S2068
daniel-teuchert-sonarsource 3e6b21d
Add reference to S2068
daniel-teuchert-sonarsource 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,11 @@ | ||
| { | ||
| "title": "Secrets should not be hard-coded", | ||
| "type": "VULNERABILITY", | ||
| "quickfix": "infeasible", | ||
| "code": { | ||
| "impacts": { | ||
| "SECURITY": "LOW" | ||
| }, | ||
| "attribute": "TRUSTWORTHY" | ||
| } | ||
| } | ||
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,54 @@ | ||
| include::../../../shared_content/secrets/description.adoc[] | ||
|
|
||
| This rule detects secrets like api keys being hard-coded in the source code. | ||
|
|
||
| == Why is this an issue? | ||
|
|
||
| include::../../../shared_content/secrets/rationale.adoc[] | ||
|
|
||
| === What is the potential impact? | ||
|
|
||
| Below are some real-world scenarios that illustrate some impacts of an attacker | ||
| exploiting the secret. | ||
|
|
||
| include::../../../shared_content/secrets/impact/security_downgrade.adoc[] | ||
|
|
||
| include::../../../shared_content/secrets/impact/data_compromise.adoc[] | ||
|
|
||
| include::../../../shared_content/secrets/impact/financial_loss.adoc[] | ||
|
|
||
| == How to fix it | ||
|
|
||
| include::../../../shared_content/secrets/fix/revoke.adoc[] | ||
|
|
||
| include::../../../shared_content/secrets/fix/vault.adoc[] | ||
|
|
||
| === Code Examples | ||
|
|
||
| ==== Noncompliant Code Example | ||
|
|
||
| [source,properties,diff-id=1,diff-type=noncompliant] | ||
| ---- | ||
| api_key=iN1KtmV2xIgdtOs1la7ugo1Pt7gLDjykprJsTELMuULRJQrlBoftwZn92Redve5k // Noncompliant | ||
| ---- | ||
|
|
||
| ==== Compliant Solution | ||
|
|
||
| Use placeholders that will be replaced by the actual secret by the build system or framework, environment variables or a secrets management service in order to not hard-code secrets in the source code. | ||
|
|
||
| [source,properties,diff-id=1,diff-type=compliant] | ||
| ---- | ||
| api_key=${MY_API_KEY} | ||
| ---- | ||
|
|
||
| == Resources | ||
|
|
||
| === Related rules | ||
|
|
||
| * S2068 - Credentials should not be hard-coded | ||
|
|
||
| === Standards | ||
|
|
||
| * OWASP - https://owasp.org/Top10/A07_2021-Identification_and_Authentication_Failures/[Top 10 2021 Category A7 - Identification and Authentication Failures] | ||
| * OWASP - https://owasp.org/www-project-top-ten/2017/A2_2017-Broken_Authentication[Top 10 2017 Category A2 - Broken Authentication] | ||
| * CWE - https://cwe.mitre.org/data/definitions/798[CWE-798 - Use of Hard-coded Credentials] |
Oops, something went wrong.
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.