Detecting infrastructure as code files using a broker
If you are using a privately hosted Git repository, Snyk Broker can connect it with Snyk products. See the broker documentation for details.
This document describes the additional configuration required for Infrastructure as Code files.

Writing the configuration

You will need to grant the broker access to particular files in the repository. This requires specific API permissions. These API permissions are slightly different depending on which source control system you are using. The configuration below is for the file extensions “.yaml”, “.yml”, and “.json”, which will allow the broker to access potential Kubernetes and CloudFormation files, but please adapt it as necessary. For example, you may wish to add configurations for “.tf” files, in order to scan Terraform HCL files.
    1.
    Find and download the appropriate accept.json sample file for your source control system from the Broker repository.
    2.
    Rename it to accept.json and add the below rules, appropriate to your SCM, to the private array in the JSON file.
    3.
    Follow the Configuring the broker instructions.

GitHub & GitHub Enterprise rules

1
{
2
"//": "used to determine Infrastructure as Code issues",
3
"method": "GET",
4
"path": "/repos/:name/:repo/contents/:path*/*.yaml",
5
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
6
},
7
{
8
"//": "used to determine Infrastructure as Code issues",
9
"method": "GET",
10
"path": "/repos/:name/:repo/contents/:path*%2F*.yaml",
11
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
12
},
13
{
14
"//": "used to determine Infrastructure as Code issues",
15
"method": "GET",
16
"path": "/repos/:name/:repo/contents/:path*/*.yml",
17
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
18
},
19
{
20
"//": "used to determine Infrastructure as Code issues",
21
"method": "GET",
22
"path": "/repos/:name/:repo/contents/:path*%2F*.yml",
23
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
24
},
25
{
26
"//": "used to determine Infrastructure as Code issues",
27
"method": "GET",
28
"path": "/repos/:name/:repo/contents/:path*/*.json",
29
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
30
},
31
{
32
"//": "used to determine Infrastructure as Code issues",
33
"method": "GET",
34
"path": "/repos/:name/:repo/contents/:path*%2F*.json",
35
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
36
},
37
{
38
"//": "used to determine Infrastructure as Code issues",
39
"method": "GET",
40
"path": "/repos/:name/:repo/contents/:path*/*.tpl",
41
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
42
},
43
{
44
"//": "used to determine Infrastructure as Code issues",
45
"method": "GET",
46
"path": "/repos/:name/:repo/contents/:path*%2F*.tpl",
47
"origin": "https://${GITHUB_TOKEN}@${GITHUB_API}"
48
},
Copied!

Bitbucket rules

1
{
2
"//": "used to determine Infrastructure as Code issues",
3
"method": "GET",
4
"path": "/projects/:project/repos/:repo/browse*/*.yaml",
5
"origin": "https://${BITBUCKET_API}",
6
"auth": {
7
"scheme": "basic",
8
"username": "${BITBUCKET_USERNAME}",
9
"password": "${BITBUCKET_PASSWORD}"
10
}
11
},
12
{
13
"//": "used to determine Infrastructure as Code issues",
14
"method": "GET",
15
"path": "/projects/:project/repos/:repo/browse*%2F*.yaml",
16
"origin": "https://${BITBUCKET_API}",
17
"auth": {
18
"scheme": "basic",
19
"username": "${BITBUCKET_USERNAME}",
20
"password": "${BITBUCKET_PASSWORD}"
21
}
22
},
23
{
24
"//": "used to determine Infrastructure as Code issues",
25
"method": "GET",
26
"path": "/projects/:project/repos/:repo/browse*/*.yml",
27
"origin": "https://${BITBUCKET_API}",
28
"auth": {
29
"scheme": "basic",
30
"username": "${BITBUCKET_USERNAME}",
31
"password": "${BITBUCKET_PASSWORD}"
32
}
33
},
34
{
35
"//": "used to determine Infrastructure as Code issues",
36
"method": "GET",
37
"path": "/projects/:project/repos/:repo/browse*%2F*.yml",
38
"origin": "https://${BITBUCKET_API}",
39
"auth": {
40
"scheme": "basic",
41
"username": "${BITBUCKET_USERNAME}",
42
"password": "${BITBUCKET_PASSWORD}"
43
}
44
},
45
{
46
"//": "used to determine Infrastructure as Code issues",
47
"method": "GET",
48
"path": "/projects/:project/repos/:repo/browse*/*.json",
49
"origin": "https://${BITBUCKET_API}",
50
"auth": {
51
"scheme": "basic",
52
"username": "${BITBUCKET_USERNAME}",
53
"password": "${BITBUCKET_PASSWORD}"
54
}
55
},
56
{
57
"//": "used to determine Infrastructure as Code issues",
58
"method": "GET",
59
"path": "/projects/:project/repos/:repo/browse*%2F*.json",
60
"origin": "https://${BITBUCKET_API}",
61
"auth": {
62
"scheme": "basic",
63
"username": "${BITBUCKET_USERNAME}",
64
"password": "${BITBUCKET_PASSWORD}"
65
}
66
},
67
{
68
"//": "used to determine Infrastructure as Code issues",
69
"method": "GET",
70
"path": "/projects/:project/repos/:repo/browse*/*.tpl",
71
"origin": "https://${BITBUCKET_API}",
72
"auth": {
73
"scheme": "basic",
74
"username": "${BITBUCKET_USERNAME}",
75
"password": "${BITBUCKET_PASSWORD}"
76
}
77
},
78
{
79
"//": "used to determine Infrastructure as Code issues",
80
"method": "GET",
81
"path": "/projects/:project/repos/:repo/browse*%2F*.tpl",
82
"origin": "https://${BITBUCKET_API}",
83
"auth": {
84
"scheme": "basic",
85
"username": "${BITBUCKET_USERNAME}",
86
"password": "${BITBUCKET_PASSWORD}"
87
}
88
},
Copied!

GitLab rules

1
{
2
"//": "used to determine Infrastructure as Code issues",
3
"method": "GET",
4
"path": "/api/v4/projects/:project/repository/files*/*.yaml",
5
"origin": "https://${GITLAB}"
6
},
7
{
8
"//": "used to determine Infrastructure as Code issues",
9
"method": "GET",
10
"path": "/api/v4/projects/:project/repository/files*%2F*.yaml",
11
"origin": "https://${GITLAB}"
12
},
13
{
14
"//": "used to determine Infrastructure as Code issues",
15
"method": "GET",
16
"path": "/api/v4/projects/:project/repository/files*/*.yml",
17
"origin": "https://${GITLAB}"
18
},
19
{
20
"//": "used to determine Infrastructure as Code issues",
21
"method": "GET",
22
"path": "/api/v4/projects/:project/repository/files*%2F*.yml",
23
"origin": "https://${GITLAB}"
24
},
25
{
26
"//": "used to determine Infrastructure as Code issues",
27
"method": "GET",
28
"path": "/api/v4/projects/:project/repository/files*/*.json",
29
"origin": "https://${GITLAB}"
30
},
31
{
32
"//": "used to determine Infrastructure as Code issues",
33
"method": "GET",
34
"path": "/api/v4/projects/:project/repository/files*%2F*.json",
35
"origin": "https://${GITLAB}"
36
},
37
{
38
"//": "used to determine Infrastructure as Code issues",
39
"method": "GET",
40
"path": "/api/v4/projects/:project/repository/files*/*.tpl",
41
"origin": "https://${GITLAB}"
42
},
43
{
44
"//": "used to determine Infrastructure as Code issues",
45
"method": "GET",
46
"path": "/api/v4/projects/:project/repository/files*%2F*.tpl",
47
"origin": "https://${GITLAB}"
48
},
Copied!

Configuring the broker

The broker takes the path to the accept.json file (with the rules above added) in the ACCEPT environment variable. You can see an example of passing that to the GitHub broker below.
1
docker run --restart=always \
2
-p 8000:8000 \
3
-e BROKER_TOKEN=secret-broker-token \
4
-e GITHUB_TOKEN=secret-github-token \
5
-e PORT=8000 \
6
-e BROKER_CLIENT_URL=https://my.broker.client:8000 \
7
-e ACCEPT=/private/accept.json
8
-v /local/path/to/private:/private \
9
snyk/broker:github-com
Copied!
Note that this gives Snyk the ability to query for any .yaml, .yml or .json files. If you would prefer to be stricter you can alter the paths in the examples above to be more restrictive to certain projects or file layouts.
Last modified 20d ago