How to build a Windows-based Docker image for CAST Highlight code scans
> docker version
This should return something like this:
Client: Docker Engine – Community
Version: 19.03.5
API version: 1.40
Go version: go1.12.12
Git commit: 633a0ea
Built: Wed Nov 13 07:22:37 2019
OS/Arch: windows/amd64
Experimental: falseServer: Docker Engine – Community
Engine:
Version: 19.03.5
API version: 1.40 (minimum version 1.12)
Go version: go1.12.12
Git commit: 633a0ea
Built: Wed Nov 13 07:29:19 2019
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.2.10
GitCommit: b34a5c8af56e510852c35414db4c1f4fa6172339
runc:
Version: 1.0.0-rc8+dev
GitCommit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
docker-init:
Version: 0.18.0
GitCommit: fec3683
mkdir win-hl
Copy the JAR of the CAST Highlight command line to this directory
copy Highlight-Automation-Command-5.1.17.tar.gz win-hl
Create a Dockerfile in the same directory and add the code below:
ENV PERL_VERSION 5.26.1.1
ENV PERL_SHA256 1bb54d7f5e487ff468bf980dbfd9962fb9d83ff1f10ccde008e0bee1f1f5b6ce
RUN powershell -Command $ErrorActionPreference = 'Stop' ; $ProgressPreference = 'SilentlyContinue' ; \
Invoke-WebRequest $('http://strawberryperl.com/download/{0}/strawberry-perl-{0}-64bit-portable.zip'
-f $env:PERL_VERSION) -OutFile 'perl.zip' -UseBasicParsing ; \
if ((Get-FileHash perl.zip -Algorithm sha256).Hash -ne $env:PERL_SHA256) { Write-Error 'SHA256 mismatch' } ; \
Expand-Archive -Path perl.zip -DestinationPath C:\ -Force ; \
rm perl.zip ; \
setx /M PATH $('C:\perl\site\bin;C:\perl\bin;C:\c\bin;{0}' -f $env:PATH)
ADD *.tar.gz /
WORKDIR /Highlight-Automation-Command
ENTRYPOINT [ "java", "-jar", "HighlightAutomation.jar", "--perlInstallDir", "c:/perl", "--analyzerDir", "./perl" ]
> docker build -t casthighlight/hl-agent-cli-win .
You’re now ready to run this image as a container and scan an application…
> docker run –rm -v ${PWD}:c:\sourceDir -v ${PWD}:c:\workingDir casthighlight/hl-agent-cli-win –sourceDir c:\sourceDir –workingDir c:\workingDir –skipUpload
The --rm
option tells docker to remove the container once it has finished its job.
You should get the following output from the Command Line through the container:
Enjoy your scans!