Custom approved-listing filter with Docker

The default approved-listing filter supports the bare minimum to operate on all repositories supported by Snyk. In order to customize the approved-listing filter, create the default filter locally by installing snyk-broker and running broker init [Git type]. The created accept.json is the default filter for the chosen Git type. Place the file in a separate folder such as ./private/accept.json, and provide it to the Docker container by mounting the folder and using the ACCEPT environment variable:

docker run --restart=always \
           -p 8000:8000 \
           -e BROKER_TOKEN=secret-broker-token \
           -e GITHUB_TOKEN=secret-github-token \
           -e PORT=8000 \
           -e BROKER_CLIENT_URL=https://my.broker.client:8000 \
           -e ACCEPT=/private/accept.json
           -v /local/path/to/private:/private \
       snyk/broker:github-com

To filter by header, add a validation block with the following key and values:

KeyValueValue TypeExample

header

The name of the header you wish to filter on. If this is defined then the named header must explicitly exist on the request; otherwise it will be blocked

String

accept

values

The header value must match one of the defined strings

Array<String>

["application/vnd.github.v4.sha"]

Example: To only allow the SHA Media Type accept header for requests to the GitHub Commits API, you would add the following:

{
    "method": "GET",
    "path": "/repos/:name/:repo/commits/:ref",
    "origin": "https://${GITHUB_TOKEN}@${GITHUB_API}",
    "valid": [
        {
            "header": "accept",
            "values": ["application/vnd.github.v4.sha"]
        }
    ]
}

Last updated

More information

Snyk privacy policy

© 2023 Snyk Limited | All product and company names and logos are trademarks of their respective owners.