Closed malferov closed 3 years ago
Not sure exactly how you run docker, but normally you can mount volumes in docker to share data between host and docker instance.
Used with zap, to be able to export reports
docker run -v $(pwd):/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py \ -t https://www.example.com -g gen.conf -r testreport.html
Thanks @pethers for your swift response. My nag report is commited to the source for the sake of this example. The ls
is being called from inside of the scanner container
jenkins@859f9f94dc19:~/workspace/app$ ls -l
-rw-r--r-- 1 jenkins jenkins 112 Dec 6 18:59 template.json
-rw-r--r-- 1 jenkins jenkins 397 Dec 6 18:59 template.json.nag
If scanner is called from the same shell the warning is rised
jenkins@859f9f94dc19:~/workspace/app$ sonar-scanner -Dsonar.host.url=http://sonar:9000 -Dsonar.projectKey=app -Dsonar.cfn.nag.reportFiles=template.json.nag
...
WARN: Processing:template.json.nag missing or do not end with .nag or .nagscan
It seems pathResolver.relativeFile(fileSystem.baseDir(), report).exists()
https://github.com/Hack23/sonar-cloudformation-plugin/blob/master/src/main/java/com/hack23/sonar/cloudformation/CloudformationSensor.java#L126 doesn't work as expected in docker environment.
Did you try using volume mount in docker ? Otherwise maybe as you say "Resolver.relativeFile(fileSystem.baseDir(), report).exists() doesn't work as expected in docker environment.", but not sure how to solve it.
@pethers it is not related to containers eventually. Plugin does work with .nagscan
files but wont to process .nag
one. Regardless docker or vm. My environment
SonarScanner 4.5.0.2216
SonarQube Community Edition Version 8.5.1 (build 38104)
Thanks for figuring this out.
Think I may have found the issue. Initially the nag scan did have a different format, to support both I added a check to check if new or old format was used. But fallback to nagscan content in .nag file had an extra check for filename extension.
Workaround that you found, to name file .nagscan make sense.
No immediate release plan since a workaround exists.
Hi there,
If
sonar-scanner
runs as a docker container, it can't find generated report.While running scanner, the sonar-cloudformation-plugin complains about missing report
Full scanner log