From 44534bc94e42ab4bc61f1eec0a42e830b3bdb229 Mon Sep 17 00:00:00 2001 From: Hendrik Buchwald <64110887+hendrik-buchwald-sonarsource@users.noreply.github.com> Date: Wed, 16 Oct 2024 17:02:38 +0200 Subject: [PATCH] Modify rule S7024 & S7025: Update example to trigger the rule (#4424) --- rules/S7024/secrets/rule.adoc | 2 +- rules/S7025/secrets/rule.adoc | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/rules/S7024/secrets/rule.adoc b/rules/S7024/secrets/rule.adoc index 6c64663d1f3..2868c7679b9 100644 --- a/rules/S7024/secrets/rule.adoc +++ b/rules/S7024/secrets/rule.adoc @@ -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[] diff --git a/rules/S7025/secrets/rule.adoc b/rules/S7025/secrets/rule.adoc index 005c8d95eb7..f2b95d9f8b2 100644 --- a/rules/S7025/secrets/rule.adoc +++ b/rules/S7025/secrets/rule.adoc @@ -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?