Skip to content

Commit

Permalink
SEC-1493 Renamed "linters" to "languages" for consistency.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahc23 committed Jul 13, 2021
1 parent c161a2a commit c4ad61f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,12 @@ But if you wish to select or exclude specific linters, we give you full control

### 23andMe Custom Behavior and Environment Variables

23andMe's custom super-linter introduced the ability to group linters into linter packs, which can then be toggled on or off as a group.
23andMe's custom super-linter introduced the ability to group linters into language packs, which can then be toggled on or off as a group.
As a result, the `VALIDATE_[LANGUAGE]` variables behave differently from those in the base super-linter:

- **All variables default to `false`, unless explicitly toggled to true.**
- A single linter/language can appear in multiple linter packs. Its `VALIDATE_[LANGUAGE]` variable will be set to `true` if *any* of the linter packs containing it are marked `true`, *except*...
- If there is an explicit `VALIDATE_[LANGUAGE]` variable for that specific linter/language, the variable will override all linter pack settings.
- A single linter/language can appear in multiple linter packs. Its `VALIDATE_[LANGUAGE]` variable will be set to `true` if *any* of the language packs containing it are marked `true`, *except*...
- If there is an explicit `VALIDATE_[LANGUAGE]` variable for that specific linter/language, the variable will override all language pack settings.

| **ENV VAR** | **Default Value** | **Notes** |
| -------------------------------------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -408,9 +408,9 @@ As a result, the `VALIDATE_[LANGUAGE]` variables behave differently from those i
| **VALIDATE_GITLEAKS** | `true` | Flag to enable or disable the linting process of potentially leaked secrets across all files and languages. |
| **VALIDATE_PYTHON_BANDIT** | `true` | Flag to enable or disable the linting process of the Python language. (Utilizing: bandit) |

The following is a list of supported linter packs.
The following is a list of supported language packs.

| **Linter pack** | **Included Tools** |
| **Language pack** | **Included Tools** |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| **RUN_SECURITY_TOOLS** | `CLOUDFORMATION_CFN_NAG`<br />`DOCKERFILE_HADOLINT`<br />`GITLEAKS`<br />`PYTHON_BANDIT`<br />`TERRAFORM_TERRASCAN` |
| **RUN_CODE_QUALITY_TOOLS** | _(All other tools that are currently not security tools)_ |
Expand Down
18 changes: 9 additions & 9 deletions lib/functions/validation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,23 @@ function GetValidationInfo() {
eval "${VALIDATE_LANGUAGE}=${!VALIDATE_LANGUAGE,,}"
done

# Loop through linter packs to turn on any linters in those packs.
for PACK in "${LINTER_PACKS[@]}"; do
LINTERS="${PACK}[@]"
# Loop through language packs to turn on any linters in those packs.
for PACK in "${LANGUAGE_PACKS[@]}"; do
LANGUAGES="${PACK}[@]"
# Build the RUN_*_TOOLS variable
RUN_LINTER_PACK="RUN_${PACK}"
RUN_LANGUAGE_PACK="RUN_${PACK}"

for LANGUAGE in "${!LINTERS}"; do
for LANGUAGE in "${!LANGUAGES}"; do
# Build the VALIDATE_* variable
VALIDATE_LANGUAGE="VALIDATE_${LANGUAGE}"
SHOULD_VALIDATE_LANGUAGE="SHOULD_${VALIDATE_LANGUAGE}"
if [[ -n "${!VALIDATE_LANGUAGE}" ]]; then
# If variable is explicitly set, that will override any linter pack settings.
# If variable is explicitly set, that will override any language pack settings.
continue
fi
# Should run current linter if *any* linter pack flips it to true.
# Should run current linter if *any* language pack flips it to true.
if [[ "${!SHOULD_VALIDATE_LANGUAGE}" != "true" ]]; then
eval "${SHOULD_VALIDATE_LANGUAGE}='${!RUN_LINTER_PACK}'"
eval "${SHOULD_VALIDATE_LANGUAGE}='${!RUN_LANGUAGE_PACK}'"
fi
done
done
Expand All @@ -83,7 +83,7 @@ function GetValidationInfo() {
# If variable was explicitly set, honor that.
continue
else
# Else use linter pack settings to determine whether it should run.
# Else use language pack settings to determine whether it should run.
eval "${VALIDATE_LANGUAGE}='${!SHOULD_VALIDATE_LANGUAGE:-false}'; export ${VALIDATE_LANGUAGE}"
fi
done
Expand Down
16 changes: 8 additions & 8 deletions lib/linter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ else
JAVASCRIPT_STYLE='standard'
fi

#######################
# Linter pack toggles #
#######################
#########################
# Language pack toggles #
#########################
# shellcheck disable=SC2034 # Variable is referenced indirectly
RUN_SECURITY_TOOLS="${RUN_SECURITY_TOOLS:-true}"
# shellcheck disable=SC2034 # Variable is referenced indirectly
Expand Down Expand Up @@ -300,16 +300,16 @@ LINTER_NAMES_ARRAY['YAML']="yamllint"
############################################
LINTED_LANGUAGES_ARRAY=() # Will be filled at run time with all languages that were linted

################
# Linter packs #
################
LINTER_PACKS=('SECURITY_TOOLS' 'CODE_QUALITY_TOOLS')
##################
# Language packs #
##################
LANGUAGE_PACKS=('SECURITY_TOOLS' 'CODE_QUALITY_TOOLS')
# shellcheck disable=SC2034 # Variable is referenced indirectly
SECURITY_TOOLS=('CLOUDFORMATION_CFN_NAG' 'DOCKERFILE_HADOLINT' 'GITLEAKS' 'PYTHON_BANDIT' 'TERRAFORM_TERRASCAN')
# CODE_QUALITY_TOOLS are all tools (i.e., items in LANGUAGE_ARRAY) that are not in SECURITY_TOOLS
# shellcheck disable=SC2034 # Variable is referenced indirectly
mapfile -t CODE_QUALITY_TOOLS < <(printf '%s\n' "${LANGUAGE_ARRAY[@]}" "${SECURITY_TOOLS[@]}" | sort | uniq -u)
export LINTER_PACKS
export LANGUAGE_PACKS

###################
# GitHub ENV Vars #
Expand Down

0 comments on commit c4ad61f

Please sign in to comment.