Skip to content

cypher0n3/psscriptanalyzer-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PSScriptAnalyzer-Docker

pipeline status

A basic docker image based off of Microsoft's PowerShell image which includes PSScriptAnalyzer

Pulling

PSScriptAnalzyer-Docker can be pulled from either DockerHub:

docker pull docker.io/cypher0n3/psscriptanalyzer-docker

or GitLab:

docker pull registry.gitlab.com/cypher_zero/psscriptanalyzer-docker

Tags

latest

The latest tag is always the latest, hopefully stable, build. This tag is updated automatically every Monday based on the latest PowerShell container and stable PSScriptAnalyzer.

If the pipeline status above indicates a failure, then this image is unstable.

stable-*

These tags are known stable builds as tested by the developer. These correspond to the same tag name in the code repository. Identifying numbers correspond to the date the tag was created.

Numbered tags

Numbered tags correspond to GitLab CI pipeline IIDs and should be considered development builds. Use at your own risk.

Usage

For advanced usage of PSScriptAnalyzer modules (Invoke-ScriptAnalyzer) see: https://github.com/PowerShell/PSScriptAnalyzer.

Analyze a script on your local system

Assuming you have a directory named test in your local path which contains the scripts to test:

docker run -v ./test:/test cypher0n3/psscriptanalyzer-docker:latest "Invoke-ScriptAnalyzer -Path /test/*.ps1"

In GitLab pipeline

When running in a GitLab pipeline, override the default entry point and call pwsh -c Invoke-ScriptAnalyzer as part of the script block. This is due to the way that GitLab sets up the container, etc. See below for a working example:

psscriptanalyzer:
  image:
    name: registry.gitlab.com/cypher_zero/psscriptanalyzer-docker:latest
    entrypoint: ["/bin/bash", "-c"]
  variables:
    PS1_TESTPATH: ./test/*.ps1
  script:
    - output=$(pwsh -c "Invoke-ScriptAnalyzer -Path $PS1_TESTPATH")
    - echo "${output}"
    - |
      if [[ -n ${output} ]]; then
        echo "Failures detected; see above."
        exit 1
      fi

Contributing

Code and pipeline automation for this project is maintained in GitLab here: https://gitlab.com/cypher_zero/psscriptanalyzer-docker

Please submit all issues and merge requests via the above GitLab project. Submissions and issues from other sources (e.g. GitHub) will not be addressed.

About

A basic docker image based off of Microsoft's PowerShell image (https://hub.docker.com/r/microsoft/powershell/) which includes PSScriptAnalyzer (https://github.com/PowerShell/PSScriptAnalyzer) intended for use with automated CI pipelines.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published