Set up Insights: Associating Snyk Open Source, Code, and Container Projects
The Set up Insights option is available only with Snyk AppRisk.
After you have set up insights, Snyk can set up the required linking for the chosen application.
To prioritize your Snyk Code and Snyk Open Source vulnerabilities, Snyk needs to understand the relationships between those imported Snyk Projects and the Container Project. Snyk uses the relationships between these Projects as a proxy to understand the composition of the container image.
The Set up Insights UI displays a variety of asset types, including but not limited to:
Repository assets
Packages
Container images
Scanned artifacts
These assets are directly linked to the ones displayed on the Snyk AppRisk Inventory view.
The container image is the build artifact that is deployed and running on your Kubernetes cluster, so Snyk can map your application from its source code to its deployed state by understanding the following:
The link between the Source Code and Open Source Dependencies and the image.
What images are deployed to Kubernetes, and how are they configured.
![Mapping your application](https://docs.snyk.io/~gitbook/image?url=https%3A%2F%2F2533899886-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MdwVZ6HOZriajCf5nXH%252Fuploads%252FtVvLg995ef8TmolwiTD8%252FAssociating%2520Snyk%2520OS%252C%2520Code%2520and%2520Container%2520projects.png%3Falt%3Dmedia%26token%3D909cb5e7-399c-4c14-979a-b1169c851509&width=768&dpr=4&quality=100&sign=9679adde&sv=2)
Use Project tags to link Projects
Add Snyk Project tags to all the Projects used by your application to link these Projects together and allow Snyk to represent the whole application that you are testing.
To associate two Projects together, add the exact same tag to both Projects. For example, add the same tag to your Snyk Open Source Projects and Snyk Container Project if they are related to each other.
See the examples at the end of this section.
Requirements for Project tags
The same tag must be applied to the container image and Code or Open Source Projects,
The tag must follow the specified format,
The Projects do not have to be in the same Snyk Organization to be mapped but MUST be in the same Snyk Group,
![Project tags](https://docs.snyk.io/~gitbook/image?url=https%3A%2F%2F2533899886-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MdwVZ6HOZriajCf5nXH%252Fuploads%252Ffx5udbdNehm6BZPcd63V%252FScreenshot%25202023-06-06%2520at%252023.29.29.png%3Falt%3Dmedia%26token%3Df33c8575-aae9-4d6f-818a-e1dbfb5e32d9&width=768&dpr=4&quality=100&sign=ec628b4c&sv=2)
Examples of Project tags
Single repo to a single image
In this example, there is a single repository containing your package.json which is built into an image called image-A.
![Example: single repo to single image](https://docs.snyk.io/~gitbook/image?url=https%3A%2F%2F2533899886-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MdwVZ6HOZriajCf5nXH%252Fuploads%252FJa9uANdai58FoirECpRD%252FExample%2520-%2520Single%2520repo%2520Single%2520image.png%3Falt%3Dmedia%26token%3Dffd78dc2-a015-4188-a924-d0065183ee4e&width=768&dpr=4&quality=100&sign=a15ace04&sv=2)
To map these associations, you would have the following tags set up:
github.com/my-team/front-end
package.json
Snyk Org: my-team
Project name: package.json
component=pkg:github/my-team/front-end@main
The same tag is applied to both sides
Built container image called image-A
Snyk Org: my-team
Project name: image-A
component=pkg:github/my-team/front-end@main
Multiple repos to a single image
![Example: multiple repos to single image](https://docs.snyk.io/~gitbook/image?url=https%3A%2F%2F2533899886-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MdwVZ6HOZriajCf5nXH%252Fuploads%252FQgICGqXlHHMvyh5BIwpy%252FExample%2520-%2520Multiple%2520repos%2520Single%2520image.png%3Falt%3Dmedia%26token%3D806f7334-9999-4945-840f-2a89e8cecdb4&width=768&dpr=4&quality=100&sign=dd0123d7&sv=2)
For this scenario, there are two contributing repositories.
There is a front-end repository containing the package.json scanned by Snyk Open Source and a back-end repository containing go code scanned by Snyk Code.
To map these associations, you would have the following tags set up:
github.com/my-team/front-end
package.json
Snyk Org: my-team
Project name: package.json
component=pkg:github/my-team/front-end@main
github.com/my-team/back-end
Go source code
Snyk Org: my-team
Project name: Code
component=pkg:github/my-team/back-end@main
Built container image called image-A
Snyk Org: my-team
Project name: image-A
component=pkg:github/my-team/front-end@main
component=pkg:github/my-team/back-end@main
The image has two tags applied, as there are two upstream dependencies which have different tags.
You can apply multiple tags to an image.
Monorepo to many images
![Example: monorepo to multiple images](https://docs.snyk.io/~gitbook/image?url=https%3A%2F%2F2533899886-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MdwVZ6HOZriajCf5nXH%252Fuploads%252FJ4phsyqIeLRxo8Dw9IyF%252FExample%2520-%2520Multiple%2520repos%2520Single%2520image-2.png%3Falt%3Dmedia%26token%3Deee190ff-7a65-4518-9137-29af56ea6b93&width=768&dpr=4&quality=100&sign=31ca2072&sv=2)
In this example, the application team is using a monorepo approach. The contents of the repository are built into different container images as they may be run separately.
Here we need to further differentiate the tags by scoping them more accurately.
github.com/my-team/service
package.json
Snyk Org: my-team
Project name: package.json
component=pkg:github/my-team/service/front-end@main
The tag is further scoped by specifying /front-end at the end
Built container image called my-app-frontend:latest
Snyk Org: my-team
Project name: my-app-frontend:latest
component=pkg:github/my-team/service/front-end@main
github.com/my-team/service
Go source code
Snyk Org: my-team
Project name: Code
component=pkg:github/my-team/service/back-end@main
The tag is further scoped by specifying /back-end at the end
Built container image called my-app-backend:latest
Snyk Org: my-team
Project name: my-app-backend:latest
component=pkg:github/my-team/service/back-end@main
Tags application
Project Tags can be applied as follows:
Snyk Code
API
UI
For projects created by
Git Import
Snyk Open Source
API
UI
CLI
For projects created by
Git Import
CLI Monitor
Snyk Container
API
UI
CLI
For projects created by
Git Import
CLI Monitor
Container Registry Integration
Snyk recommends applying the tags through the API in order to automate the process. For more information, see the endpoint Add a tag to a project.
UI example for Project tags
![UI example for Project tags](https://docs.snyk.io/~gitbook/image?url=https%3A%2F%2F2533899886-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MdwVZ6HOZriajCf5nXH%252Fuploads%252Fe4PCTqUKvjJtNlS1uz0O%252FuiExample.png%3Falt%3Dmedia%26token%3D5b631436-5bb1-405b-9be0-39476631c236&width=768&dpr=4&quality=100&sign=c0892799&sv=2)
CLI Example
snyk monitor --project-tags=component=pkg:github/my-team/back-end@main
API Example
See the Project Update documentation.
Example:
To ensure you have set up your Kubernetes Connector properly, navigate to the Set up Insights tab on the Insights page and check the Image composition section to view the data Insights has access to.
Last updated
Was this helpful?