Skip to content

Improve keyword key for secret detection#17

Open
DMarinhoCodacy wants to merge 1 commit into
mainfrom
improve-hardcoded-secrets-key
Open

Improve keyword key for secret detection#17
DMarinhoCodacy wants to merge 1 commit into
mainfrom
improve-hardcoded-secrets-key

Conversation

@DMarinhoCodacy
Copy link
Copy Markdown
Contributor

No description provided.

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

Copy link
Copy Markdown

@codacy-production codacy-production Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

The PR successfully introduces more granular secret detection by adding prefixes to the 'key' keyword. However, it introduces a significant logic regression in the SQL lookup-type-without-language-or-apps-fnd rule. The refactoring from pattern-either to a sequential list of patterns changes the detection logic from 'OR' to 'AND', which will cause the rule to miss many valid violations.

Additionally, there is an inconsistency in how the regex was updated. While the Java rule correctly deduplicated the keyword clave, the same duplication remains in the C#, JavaScript, and PL/SQL rules. Finally, the PR lacks a description and includes out-of-scope changes to the SQL rule that contradict the PR title.

About this PR

  • The modifications to the 'codacy.generic.sql.lookup-type-without-language-or-apps-fnd' rule appear out of scope based on the PR title and represent a significant change in behavior.
  • The PR description is missing. Please provide context regarding why these specific changes were made and why the SQL rule logic was modified.

Test suggestions

  • Verify Java rule detects 'String aws_key = "..."'
  • Verify C# rule detects 'var api-key = "..."'
  • Verify JavaScript rule detects 'const private_key = "..."'
  • Verify SQL rule flags files with 'lookup_type' AND 'apps.fnd_lookup_values' when 'language' is missing
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify Java rule detects 'String aws_key = "..."'
2. Verify C# rule detects 'var api-key = "..."'
3. Verify JavaScript rule detects 'const private_key = "..."'
4. Verify SQL rule flags files with 'lookup_type' AND 'apps.fnd_lookup_values' when 'language' is missing

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback

Comment thread docs/codacy-rules.yaml
Comment on lines +325 to +327
- pattern-regex: "(?im)^(?:(?!--|/\\*)[^\\n])*\\bapps\\.fnd_lookup_values\\b"
- pattern-regex: "(?im)^(?:(?!--|/\\*)[^\\n])*\\blookup_type\\b"
- pattern-not-regex: "(?im)^(?:(?!--|/\\*)[^\\n])*\\blanguage\\b"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 HIGH RISK

The removal of pattern-either converts the logic from OR to AND. This rule will now only trigger if both apps.fnd_lookup_values and lookup_type appear on the same line, which misses cases where only one is present. Additionally, the new patterns lose the multi-line detection capability of the previous regex (which used (?:[^;\n]*\n)*). Restore the pattern-either block to ensure valid SQL violations are still detected.

Comment thread docs/codacy-rules.yaml
- metavariable-regex:
metavariable: "$PASSWORD"
regex: "(?i).*(password|motdepasse|heslo|adgangskode|wachtwoord|salasana|passwort|passord|senha|geslo|clave|losenord|clave|parola|secret|pwd|key).*"
regex: "(?i).*(password|motdepasse|heslo|adgangskode|wachtwoord|salasana|passwort|passord|senha|geslo|clave|losenord|clave|parola|secret|pwd|(api|secret|private|access|aws|ssh|auth|session|encryption|decryption|gcp)[_-]?key).*"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ LOW RISK

Suggestion: Duplicate keyword clave detected in the regex. Please remove the redundant entry to match the clean version used in the Java rule.

Suggested change
regex: "(?i).*(password|motdepasse|heslo|adgangskode|wachtwoord|salasana|passwort|passord|senha|geslo|clave|losenord|clave|parola|secret|pwd|(api|secret|private|access|aws|ssh|auth|session|encryption|decryption|gcp)[_-]?key).*"
regex: "(?i).*(password|motdepasse|heslo|adgangskode|wachtwoord|salasana|passwort|passord|senha|geslo|clave|losenord|parola|secret|pwd|(api|secret|private|access|aws|ssh|auth|session|encryption|decryption|gcp)[_-]?key).*"

Comment thread docs/codacy-rules.yaml
- metavariable-regex:
metavariable: "$PASSWORD"
regex: "(?i).*(password|motdepasse|heslo|adgangskode|wachtwoord|salasana|passwort|passord|senha|geslo|clave|losenord|clave|parola|secret|pwd|key).*"
regex: "(?i).*(password|motdepasse|heslo|adgangskode|wachtwoord|salasana|passwort|passord|senha|geslo|clave|losenord|clave|parola|secret|pwd|(api|secret|private|access|aws|ssh|auth|session|encryption|decryption|gcp)[_-]?key).*"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ LOW RISK

Suggestion: The keyword clave is duplicated in this regex string. For consistency and efficiency, remove the redundant second occurrence.

Suggested change
regex: "(?i).*(password|motdepasse|heslo|adgangskode|wachtwoord|salasana|passwort|passord|senha|geslo|clave|losenord|clave|parola|secret|pwd|(api|secret|private|access|aws|ssh|auth|session|encryption|decryption|gcp)[_-]?key).*"
regex: "(?i).*(password|motdepasse|heslo|adgangskode|wachtwoord|salasana|passwort|passord|senha|geslo|clave|losenord|parola|secret|pwd|(api|secret|private|access|aws|ssh|auth|session|encryption|decryption|gcp)[_-]?key).*"

Comment thread docs/codacy-rules.yaml
- metavariable-regex:
metavariable: "$PASSWORD"
regex: "(?i).*(password|motdepasse|heslo|adgangskode|wachtwoord|salasana|passwort|passord|senha|geslo|clave|losenord|clave|parola|secret|pwd|key).*"
regex: "(?i).*(password|motdepasse|heslo|adgangskode|wachtwoord|salasana|passwort|passord|senha|geslo|clave|losenord|clave|parola|secret|pwd|(api|secret|private|access|aws|ssh|auth|session|encryption|decryption|gcp)[_-]?key).*"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ LOW RISK

Suggestion: The keyword clave is duplicated in the regex string. Removing the second instance will make the regex cleaner and maintain consistency with the Java rule update on line 28.

Suggested change
regex: "(?i).*(password|motdepasse|heslo|adgangskode|wachtwoord|salasana|passwort|passord|senha|geslo|clave|losenord|clave|parola|secret|pwd|(api|secret|private|access|aws|ssh|auth|session|encryption|decryption|gcp)[_-]?key).*"
regex: "(?i).*(password|motdepasse|heslo|adgangskode|wachtwoord|salasana|passwort|passord|senha|geslo|clave|losenord|parola|secret|pwd|(api|secret|private|access|aws|ssh|auth|session|encryption|decryption|gcp)[_-]?key).*"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant