# Sonar scan does not exclude the sources though its mentioned in sources exclusion

**URL:** <https://community.sonarsource.com/t/sonar-scan-does-not-exclude-the-sources-though-its-mentioned-in-sources-exclusion/61001>\
**Category:** SonarQube Server / Community Build\
**Tags:** sonarqube, scanner\
**Created:** [April 4, 2022, 3:40am UTC](https://community.sonarsource.com/t/sonar-scan-does-not-exclude-the-sources-though-its-mentioned-in-sources-exclusion/61001 "2022-04-04T03:40:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rgaduputi](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/rgaduputi/32/28878_2.png) [@rgaduputi](https://community.sonarsource.com/u/rgaduputi)\
**Post date:** [April 4, 2022, 3:40am UTC](https://community.sonarsource.com/t/sonar-scan-does-not-exclude-the-sources-though-its-mentioned-in-sources-exclusion/61001/1 "2022-04-04T03:40:23Z")

</div>

- Versions used SonarQube: 9.3 Scanner : 4.7.0.2747

We have some files/dirs `QOUTA/TestScripts` in sources which we are trying to exclude everything from this directory while executing scan, same is mentioned in properties file with `sonar.exclusions`.  
Though in the logs scanner prints that its ignoring those, but in reality it does not and fails during the scan.

We have configured this as per docs [Narrowing the Focus | SonarQube Docs](https://docs.sonarqube.org/latest/project-administration/narrowing-the-focus/) ,  
So why is it not excluding everything from this directory `QOUTA/TestScripts/**/*` ?

````auto
INFO: Project configuration:
INFO: Excluded sources: misc/ **/*, Tools/** /*, CI/ **/*, ci-cd/** /*, QOUTA/TestScripts/**/*
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 7.556s
INFO: Final Memory: 21M/100M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: QOUTA/TestScripts/Server/test_certs/aTest??z_??_S.A..pem
  	at java.base/sun.nio.fs.UnixPath.encode(UnixPath.java:145)
  	at java.base/sun.nio.fs.UnixPath.<init>(UnixPath.java:69)
  	at java.base/sun.nio.fs.UnixFileSystem.getPath(UnixFileSystem.java:279)
  	at java.base/java.nio.file.Path.resolve(Path.java:515)
  	at org.sonar.scm.git.IncludedFilesRepository.indexFiles(IncludedFilesRepository.java:65)
  	at org.sonar.scm.git.IncludedFilesRepository.<init>(IncludedFilesRepository.java:40)
  	at org.sonar.scm.git.GitIgnoreCommand.init(GitIgnoreCommand.java:37)
  	at org.sonar.scanner.scan.filesystem.ProjectFileIndexer.index(ProjectFileIndexer.java:104)```
````

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [April 4, 2022, 7:12pm UTC](https://community.sonarsource.com/t/sonar-scan-does-not-exclude-the-sources-though-its-mentioned-in-sources-exclusion/61001/2 "2022-04-04T19:12:35Z")

</div>

Hi,

Could we have the full analysis log, including the full stacktrace?

I think the files are excluded from _analysis_. The error seems to be coming from the SCM sensor, which is trying to collect data _about_ the files, rather than analyzing what’s _in_ the files. (Okay, I get it if that’s a distinction without a difference for you.) The problem seems to be the file name. Would you mind sharing the name as well?

&nbsp;  
Thx,  
Ann

---

<div class="post-metadata">

**Author:** ![rgaduputi](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/rgaduputi/32/28878_2.png) [@rgaduputi](https://community.sonarsource.com/u/rgaduputi)\
**Post date:** [April 5, 2022, 4:56am UTC](https://community.sonarsource.com/t/sonar-scan-does-not-exclude-the-sources-though-its-mentioned-in-sources-exclusion/61001/3 "2022-04-05T04:56:30Z")

</div>

Hi @ganncamp ,  
Yes, my understanding was exclude means, exclude from every where not just analysis.  
Attached is the full log and I agree file name is  
little weird `AC_Raíz_Certicámara_S.A..pem`

[scanner.log](https://community.sonarsource.com/uploads/short-url/e4F7hsLIl3xWtNh1MbmgO6UCUfi.log) (5.5 KB)

Thanks.

---

<div class="post-metadata">

**Author:** ![ganncamp](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/ganncamp/32/1261_2.png) [@ganncamp](https://community.sonarsource.com/u/ganncamp)\
**Post date:** [April 5, 2022, 1:24pm UTC](https://community.sonarsource.com/t/sonar-scan-does-not-exclude-the-sources-though-its-mentioned-in-sources-exclusion/61001/4 "2022-04-05T13:24:41Z")

</div>

Hi,

Thanks for the full analysis log, and for the full file name.

As you were already quite aware, this looks like a bug. 😃

I know that validation doesn’t help you get analysis accomplished, though. Can you try explicitly excluding `**/*.pem` files? (And let us know if that works?)

Meanwhile, I’m going to refer this to the team to get attention on this bug handling non-UTF-8 characters in file names.

&nbsp;  
Ann

---

<div class="post-metadata">

**Author:** ![rgaduputi](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/rgaduputi/32/28878_2.png) [@rgaduputi](https://community.sonarsource.com/u/rgaduputi)\
**Post date:** [April 8, 2022, 8:59am UTC](https://community.sonarsource.com/t/sonar-scan-does-not-exclude-the-sources-though-its-mentioned-in-sources-exclusion/61001/6 "2022-04-08T08:59:06Z")

</div>

Hi @ganncamp ,  
Thanks. Excluding `**/*.pem` did not help either it fails with same.

`Excluded sources: misc/ **/*, Tools/** /*, CI/ **/*, ci-cd/** /*, **/test/*, QUOTA/TestScripts/** /*, **/*.pem`

`ERROR: Error during SonarScanner execution java.nio.file.InvalidPathException: Malformed input or input contains unmappable characters: QUOTA/TestScripts/Server/test_certs/AC_Ra??z_Certic??mara_S.A..pem at java.base/sun.nio.fs.UnixPath.encode(UnixPath.java:145)`
