globocom / huskyCI

Performing security tests inside your CI
https://huskyci.opensource.globo.com
BSD 3-Clause "New" or "Revised" License
572 stars 137 forks source link

Implementing Language Exclusion for analysis #528

Closed GabhenDM closed 3 years ago

GabhenDM commented 3 years ago

Description

We recently had an issue with a project where HuskyCI would run NPMAudit and YarnAudit due to a subproject folder containing UI code. We wanted to exclude that validation and noticed there was no resource for disabling a specific language analysis from being executed.

Proposed Changes

This PR introduces a new environment variable "HUSKYCI_LANGUAGE_EXCLUSIONS", which is a comma separated list of languages to be excluded from the analysis flow.

A map containing the values is sent by the client to the API, which is then used after the enryScan is executed, where it check if any of the identified languages on the project is included in the exclusion list, removing it from list of repo languages to be analyzed.

Testing

By adding the env variable HUSKYCI_LANGUAGE_EXCLUSIONS and executing make run-client, one should be able to turn off language specific validations from being executed.

Example:

export HUSKYCI_LANGUAGE_EXCLUSIONS=JavaScript,Ruby
tcarreira commented 3 years ago

Nice one. Would you mind gofmt it before merging? gofmt -w -l api

GabhenDM commented 3 years ago

Nice one. Would you mind gofmt it before merging? gofmt -w -l api

Sure thing! just pushed the changes😄