docker:S6505 is outdated and too extreme

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.

Hi Krisztian,
Thank you very much for your post!
I looked into npm’s behavior and the --strict-allow-scripts flag, and I agree that restricting script execution to explicitly reviewed and approved dependencies is a valid alternative to disabling scripts entirely.

I’ve created a ticket to improve both the detection logic and the rule description across all supported languages. We also already had an internal ticket about adjusting this rule to the npm v12 default behavior changes but it did not get prioritized yet.

Thank you again for your contribution and for helping us improve our rules.

Best,
Daniel