Let’s say I have this Dockerfile using NPM v11:
FROM dhi.io/node:24.22.1-alpine3.24-dev@sha256:7b851ff65d774343caf89450555663caef54dbd8f673658a615d256883973337 AS installer
WORKDIR /app
ENV NODE_ENV=production
COPY package.json package-lock.json ./
RUN npm ci --production --strict-allow-scripts && npm cache clean --force
SonarQube does not like my npm ci command:
Omitting “--ignore-scripts” allows lifecycle scripts to run during package installation.sonarqube(docker:S6505)
I disagree with the rule because I think --ignore-scripts is extreme measure. I understand that security is important, but security practices ideally shouldn’t hinder productivity or what we can do as software engineers. Sometimes those scripts cannot be avoided without breaking things.
By the way, this is a Node v11 feature. Node v12 goes even further and turn the --strict-allow-scripts flag on by default.
Therefore, I think on the long run, the rule shouldn’t be necessary anymore, furthermore, I think we can already improve the description of the rule so that it recommends either --strict-allow-scripts (recommended) or --ignore-scripts (as last resort). Sadly, I understand the difficulty behind detecting the NPM version, so I can’t suggest an ideal future for this rule.
Thanks for considering.