Scanning with the CodeLogic .NET Agent (Docker)
The CodeLogic .NET Agent for Docker provides an easy way to integrate CodeLogic scanning into your build process.
- Generate the Docker Image
- Run the Docker Image
- View Scan Results
- Using the Docker agent with Jenkins
Generate the Docker Image
- Click Admin and then select the Installers tab.
- Locate the .NET Agent Docker Image tile and click Generate.
- Enter your CodeLogic Server IP address or hostname.
- Enter the directory path to be scanned in the field provided.
- Click Next.
-
Copy your code snippet from the Success! window.
Docker Options Examples
- --pull always - ensures that you will always get the newest image
- --env CODELOGIC_NETCAPE__URL="https://codelogic.com/codelogic/server/" - passes an environment variable representing the IP address or hostname of the CodeLogic Server
- --env AGENT_UUID="1f5d0bbc-0924-4c6f-828c-532627c33178" - passes an environment variable for the agent UUID
- --env AGENT_PASSWORD="AahlDFNbb0PyU378" - passes an environment variable for the agent password
- --volume "C:\Users\User\Documents\yourAppsDlls:/scan" - mounts the directory
C:\Users\User\Documents\yourAppsDlls
onto the directory/scan
so that it is accessible by the docker container - codelogic.com/codelogic_dotnet:latest - tells docker to download the .NET agent codelogic_dotnet:latest from the CodeLogic Server
- See Docker Documentation for more docker options.
Run the Docker Image
Tip
You can copy and paste the code snippet directly into your Jenkins file.
analyze an application, omit the -d option if no database is utilized
analyze -a dynamicDemoApp --path /scan -d jdbc:postgresql://localhost:5432/sampledb
For more information, see Binary Scanning via Command Line (.NET).
View Scan Results
- Select the Search tab.
- Expand the application to view items and their dependencies.
CI/CD Scanning
Using the Docker agent with Jenkins
The CodeLogic .NET Agent for Docker can be used to scan artifacts in Jenkins pipelines.
Example:
stage('CodeLogic Scan EKS') {
when {
expression { BRANCH_NAME ==~ /(integration|v.*|feature\/.*)/ }
}
steps {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
// Publish CodeLogic Scan
sh('''
docker run --pull always --rm --interactive \
--env CODELOGIC_NETCAPE__URL="https://yourinstance.app.codelogic.com/codelogic/server/" \
--env "AGENT_UUID=${AGENT_UUID}" \
--env "AGENT_PASSWORD=${AGENT_PASSWORD}" \
--volume "${WORKSPACE}/NetCape/installdir":/home/codelogic/analysis_target \
yourinstance.app.codelogic.com/codelogic_dotnet:latest analyze \
--application "Your Application" \
--path /home/codelogic/analysis_target/ \
--scan-space-name "Development" \
--filter Example \
--method-filter Example \
--recursive com.example \
--rescan \
--expunge-scan-sessions
''')
}
}
}