Skip to content

[java] Fix #7007: HardCodedCryptoKey detection for String(char[]) - #7029

Merged
UncleOwen merged 3 commits into
pmd:mainfrom
suhanrain:fix-7007-hardcoded-crypto-key
Sep 8, 2026
Merged

UncleOwen merged 3 commits into
pmd:mainfrom
suhanrain:fix-7007-hardcoded-crypto-key

Conversation

@suhanrain

Copy link
Copy Markdown
Contributor

Summary

  • detect hard-coded cryptographic keys constructed with String(char[])
  • follow the character-array initializer while avoiding dynamic array contents
  • add regression coverage for hard-coded and dynamic character arrays

Testing

  • ./mvnw -pl pmd-java -Dtest='net.sourceforge.pmd.lang.java.rule.security.*Test' test
  • ./mvnw -pl pmd-java -DskipTests checkstyle:check
  • git diff --check

Closes #7007

@pmd-actions-helper

pmd-actions-helper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.

Regression Tester Report

(comment created at 2026-09-08 12:17:19+00:00 for 6393316)

@UncleOwen UncleOwen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@UncleOwen UncleOwen added this to the 7.28.0 milestone Sep 8, 2026
@UncleOwen
UncleOwen merged commit f7d3cf1 into pmd:main Sep 8, 2026
13 checks passed
@adangel adangel changed the title [java] Fix HardCodedCryptoKey detection for String(char[]) [java] Fix #7007: HardCodedCryptoKey detection for String(char[]) Sep 8, 2026
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.

[java] HardCodedCryptoKey: False negative when a hard-coded key is constructed via new String(char[])

2 participants