SonarCloud Scan Not Covering .txt Files Containing Hardcoded Secrets

We are facing an issue with SonarCloud analysis where plain-text (.txt) files are not being covered by the scan. One of these .txt files contains a hardcoded secret in plain text, but no security finding is being generated.

From the scanner logs, we observed the following configuration:

Project configuration:

Excluded sources: **/node_modules/**, **/.git/**, **/build-wrapper-dump.json, **/*.txt

Included tests: **/*.txt

The .txt files appear under Excluded sources and are also being treated as Included tests. Due to this behavior, the files containing hardcoded secrets are not being analyzed as expected.

We have attempted to include the files in the analysis using configurations such as:

# Include TXT files for text/secrets analysis

 sonar.text.inclusions.activate=true

 sonar.text.inclusions=\*\*/\*.txt

However, the .txt files are still not being covered by the SonarCloud scan as expected, and the hardcoded secrets remain undetected.

Expected behavior:

We would like SonarCloud to:

  1. Include .txt files in the scan.
  2. Perform Secrets analysis on these files.
  3. Report hardcoded secrets when they match supported secret-detection rules.

Could you please help us confirm:

  • Why are **/*.txt files automatically appearing under Excluded sources and Included tests?
  • How can we configure SonarCloud so that .txt files are included in the appropriate analysis scope?
  • Is any additional configuration required to enable secret detection for .txt files?
  • Are there any limitations on the types of hardcoded credentials/secrets that SonarCloud can detect in .txt files?

Please advise on the recommended configuration to ensure that .txt files are scanned and hardcoded secrets within them are detected.

Hey @Jasmin.shaikh16, you have added .txt files to sonar.text.inclusions, but have you removed it from the Excluded sources?

Hi Andres,
We have not excluded .txt file from the UI, we have only added the inclusions of .txt.

The way you wrote it, it’s not really clear to me what you mean, so I want to confirm: are you still passing **/*.txt to “Excluded sources”?