securitysnyk

How do we ignore folders in Snyk


How can I ignore/exclude folders or directories when scanning a project at Snyk, whether in CLI or in SCM scan?

It seems that an import of a Snyk Code or Snyk Open Source project don't behave in the same way.


Solution

  • Yes, unfortunately this is confusing today. For historical reasons, the .snyk file only applies to Snyk Code (SAST).

    To exclude directories for the open source part, you need to:

    In an SCM import, add the list to exclude (screenshot) In a CLI import, add the directories as arguments (syntax below) --exclude=DIRECTORY[,DIRECTORY]...> (only in test and monitor commands) Can be used with --all-projects and --yarn-workspaces to indicate sub-directories and files to exclude. Must be comma separated.

    This is confusing because these are two separate mechanisms. In the future, both mechanisms will be the same, but for now, both need to be done.