FROM microsoft/dotnet:2.2-sdk # Install PowerShell Core RUN apt-get update && \ apt-get install -y curl gnupg apt-transport-https && \ curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \ sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch main" > /etc/apt/sources.list.d/microsoft.list' && \ apt-get update && \ apt-get install -y --allow-unauthenticated powershell # Create a directory to store tool findings WORKDIR /opt/codedx/securitycodescan/work/output # Create a directory to store the PowerShell Core scripts WORKDIR /opt/codedx/securitycodescan/script # Copy both SecurityCodeScan.ps1 and SecurityCodeScan-Rules.ps1 to the script directory COPY SecurityCodeScan.ps1 . COPY SecurityCodeScan-Rules.ps1 . # Create a new user and grant the user permissions to the /opt/codedx/securitycodescan directory content RUN useradd -m --shell /bin/sh securitycodescan --uid 1000 RUN chown -R securitycodescan:securitycodescan /opt/codedx/securitycodescan USER 1000 # Configure containers to run sh by default CMD ["sh"]