Skip to content

Commit

Permalink
Modify rule S7024 & S7025: Update example to trigger the rule (#4424)
Browse files Browse the repository at this point in the history
  • Loading branch information
hendrik-buchwald-sonarsource authored Oct 16, 2024
1 parent fab84d0 commit 44534bc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rules/S7024/secrets/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ include::../../../shared_content/secrets/fix/vault.adoc[]
=== Code examples

:example_secret: 891c8ed850cddbece40760b800867f1231d43f2d2586
:example_name: ibm-cloud.cos_hmac.secret-access-key
:example_name: ibm-cloud.cos_hmac.secret_access_key
:example_env: COS_HMAC_SECRET_ACCESS_KEY

include::../../../shared_content/secrets/examples.adoc[]
Expand Down
18 changes: 14 additions & 4 deletions rules/S7025/secrets/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,21 @@ include::../../../shared_content/secrets/fix/vault.adoc[]

=== Code examples

:example_secret: 10db3f279df241bad2a9692a6a412f80bf3cadba00ace324a1cf6f159f00d019
:example_name: cloudant.password
:example_env: CLOUDANT_PASSWORD
==== Noncompliant code example

include::../../../shared_content/secrets/examples.adoc[]
[source,java,diff-id=1,diff-type=noncompliant,subs="attributes"]
----
props.set("cloudant.username", "name");
props.set("cloudant.password", "10db3f279df241bad2a9692a6a412f80bf3cadba00ace324a1cf6f159f00d019"); // Noncompliant
----

==== Compliant solution

[source,java,diff-id=1,diff-type=compliant,subs="attributes"]
----
props.set("cloudant.username", System.getenv("CLOUDANT_USERNAME"));
props.set("cloudant.password", System.getenv("CLOUDANT_PASSWORD"));
----

//=== How does this work?

Expand Down

0 comments on commit 44534bc

Please sign in to comment.