Add run-install-scripts flag to disable npm pre/post install scripts by default#24863
Add run-install-scripts flag to disable npm pre/post install scripts by default#24863
Conversation
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/744e4164-27d0-4991-b0d7-594f812a7c14 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/744e4164-27d0-4991-b0d7-594f812a7c14 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot rename run-scripts to run-install-scripts |
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/eaec605c-e5b6-4781-936e-4744f3448919 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in 75d5400. Renamed Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
📰 DEVELOPING STORY: Smoke Copilot ARM64 reports was cancelled. Our correspondents are investigating the incident... |
|
❌ Smoke Project encountered failures. Check the logs for details. |
|
❌ Smoke Multi PR failed to create multiple PRs. Check the logs. |
|
📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing... |
There was a problem hiding this comment.
Pull request overview
This PR hardens generated workflow npm installs by defaulting to --ignore-scripts to prevent execution of npm lifecycle hooks, and introduces a run-install-scripts frontmatter opt-in that surfaces warnings (or errors in strict mode).
Changes:
- Add workflow-level resolution + validation for
run-install-scripts(including import propagation). - Update generated npm install commands to include
--ignore-scriptsby default. - Regenerate affected workflow lock files and update unit tests/schema for the new setting.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/run_install_scripts_validation.go | Adds resolution + compiler validation for run-install-scripts. |
| pkg/workflow/run_install_scripts_validation_test.go | Adds unit tests covering resolution, npm step generation, and validation behavior. |
| pkg/workflow/nodejs.go | Adds runInstallScripts plumbing and defaults npm install to --ignore-scripts. |
| pkg/workflow/qmd.go | Adds --ignore-scripts to qmd SDK npm install step. |
| pkg/workflow/frontmatter_types.go | Extends typed frontmatter/runtime configs to include run-install-scripts. |
| pkg/workflow/engine_helpers.go | Passes WorkflowData.RunInstallScripts into npm engine install step generation. |
| pkg/workflow/compiler_types.go | Stores resolved RunInstallScripts on WorkflowData. |
| pkg/workflow/compiler_orchestrator_tools.go | Resolves RunInstallScripts from frontmatter + merged runtimes + imports. |
| pkg/workflow/compiler_orchestrator_workflow.go | Invokes run-install-scripts validation during workflow parsing. |
| pkg/workflow/claude_engine_test.go | Updates expected install commands to include --ignore-scripts. |
| pkg/workflow/engine_includes_test.go | Updates lockfile expectation for npm install to include --ignore-scripts. |
| pkg/parser/import_processor.go | Adds MergedRunInstallScripts to imports result to propagate import settings. |
| pkg/parser/import_field_extractor.go | Extracts run-install-scripts from imported workflows (global and node runtime). |
| pkg/parser/schemas/main_workflow_schema.json | Documents run-install-scripts at top-level and per-runtime in schema. |
| actions/setup/setup.sh | Adds --ignore-scripts to runtime installation of @actions/github. |
| .github/workflows/weekly-blog-post-writer.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/unbloat-docs.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/typist.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/test-create-pr-error-handling.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/technical-doc-writer.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/step-name-alignment.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/static-analysis-report.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/smoke-gemini.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/smoke-codex.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/smoke-claude.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/smoke-call-workflow.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/smoke-agent-scoped-approved.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/smoke-agent-public-none.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/smoke-agent-public-approved.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/smoke-agent-all-none.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/smoke-agent-all-merged.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/sergo.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/semantic-function-refactor.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/scout.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/schema-feature-coverage.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/schema-consistency-checker.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/safe-output-health.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/prompt-clustering-analysis.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/lockfile-stats.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/issue-arborist.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/instructions-janitor.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/hourly-ci-cleaner.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/grumpy-reviewer.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/go-pattern-detector.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/go-logger.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/go-fan.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/glossary-maintainer.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/github-mcp-tools-report.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/github-mcp-structural-analysis.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/example-workflow-analyzer.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/duplicate-code-detector.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/dictation-prompt.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/developer-docs-consolidator.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/dev.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/deep-report.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/daily-team-evolution-insights.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/daily-security-red-team.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/daily-safe-outputs-conformance.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/daily-safe-output-optimizer.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/daily-rendering-scripts-verifier.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/daily-otel-instrumentation-advisor.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/daily-observability-report.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/daily-multi-device-docs-tester.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/daily-function-namer.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/daily-fact.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/daily-doc-updater.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/daily-doc-healer.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/daily-code-metrics.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/daily-choice-test.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/copilot-session-insights.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/copilot-agent-analysis.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/commit-changes-analyzer.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/codex-github-remote-mcp-test.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/cloclo.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/cli-version-checker.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/claude-code-user-docs-review.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/ci-doctor.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/changeset.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/blog-auditor.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/audit-workflows.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
| .github/workflows/ai-moderator.lock.yml | Regenerated lock workflow with --ignore-scripts on npm installs. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 81/81 changed files
- Comments generated: 4
| // Validate run-install-scripts setting (warning in non-strict mode, error in strict mode) | ||
| if err := c.validateRunInstallScripts(workflowData); err != nil { | ||
| return nil, fmt.Errorf("%s: %w", cleanPath, err) | ||
| } |
There was a problem hiding this comment.
validateRunInstallScripts is executed after setupEngineAndImports restores c.strictMode back to its initial (CLI) value, so workflows that are strict via frontmatter default/strict: true will incorrectly get a warning instead of an error. Consider running this validation while c.strictMode is set to effectiveStrictMode(result.Frontmatter) (similar to validateUpdateCheck), or compute strictness from workflowData.RawFrontmatter inside the validator.
| if c.strictMode { | ||
| return fmt.Errorf("strict mode: %s", warningMsg) | ||
| } | ||
|
|
||
| fmt.Fprintln(os.Stderr, console.FormatWarningMessage(warningMsg)) |
There was a problem hiding this comment.
This validator uses c.strictMode, but that field represents the CLI flag and may not reflect the workflow’s effective strictness (frontmatter default is strict). Use c.effectiveStrictMode(workflowData.RawFrontmatter) (or pass the effective strict value in) to decide between warning vs error, otherwise run-install-scripts: true won’t be rejected in strict workflows unless the CLI strict flag is set.
| // Install the @tobilu/qmd SDK into the gh-aw actions directory so qmd_index.cjs | ||
| // can require('@tobilu/qmd') via the adjacent node_modules folder. | ||
| npmInstall := " - name: Install @tobilu/qmd SDK\n" | ||
| npmInstall += ifCacheMiss | ||
| npmInstall += " run: |\n" | ||
| npmInstall += fmt.Sprintf(" npm install --prefix \"${{ runner.temp }}/gh-aw/actions\" --legacy-peer-deps @tobilu/qmd@%s @actions/github\n", version) | ||
| npmInstall += fmt.Sprintf(" npm install --ignore-scripts --prefix \"${{ runner.temp }}/gh-aw/actions\" --legacy-peer-deps @tobilu/qmd@%s @actions/github\n", version) | ||
| steps = append(steps, npmInstall) |
There was a problem hiding this comment.
The generated qmd install command always includes --ignore-scripts and does not appear to respect the new run-install-scripts: true opt-in. If run-install-scripts is intended to disable --ignore-scripts for all generated npm installs, thread WorkflowData.RunInstallScripts into qmd step generation (e.g., by passing a flag into generateQmdIndexSteps) and conditionally omit the flag.
| "run-install-scripts": { | ||
| "type": "boolean", | ||
| "default": false, | ||
| "description": "Allow npm pre/post install scripts to execute for this runtime during package installation. Overrides the global run-install-scripts setting for this specific runtime. Only affects runtimes that generate npm install commands (node). A supply chain security warning is emitted at compile time; in strict mode this is an error.", | ||
| "examples": [false, true] |
There was a problem hiding this comment.
Schema text says per-runtime run-install-scripts "overrides" the global setting, but the current resolution logic is OR-based (any true enables scripts) and there’s no way for a per-runtime false to override a global true. Either adjust the schema description to match the implemented semantics, or implement precedence/override behavior.
Summary
Updates the runtime manager to emit
--ignore-scriptson all generatednpm installcommands by default, preventing supply chain attacks via malicious npm package install hooks. Adds arun-install-scriptsopt-in field for workflows that legitimately need install scripts to execute.Problem
npm packages can execute arbitrary code during installation via
preinstall,postinstall, and other lifecycle scripts. Malicious or compromised packages can use these hooks to exfiltrate secrets, install backdoors, or corrupt the runner environment. This is a known supply chain attack vector.Previously, the runtime manager generated bare
npm installcommands with no protection against install scripts.Changes
Default behaviour (breaking for install scripts)
All generated
npm installcommands now include--ignore-scripts:Affected locations:
pkg/workflow/nodejs.go— engine CLI installs (Claude, Codex, Gemini)pkg/workflow/qmd.go— QMD documentation tool installactions/setup/setup.sh— framework@actions/githubinstallNew
run-install-scriptsfrontmatter fieldUsers who need install scripts can opt in globally or per-runtime:
When
run-install-scripts: trueis set:Shared workflow support
The
run-install-scriptssetting from imported shared agentic workflows is propagated correctly:run-install-scriptsmerges via the existingmergeRuntimesmechanismrun-install-scriptsis extracted from imports via a newMergedRunInstallScripts boolfield inImportsResultSchema
run-install-scriptsis documented in the JSON schema (both at top-level and inruntimes.*) and will appear in IDE autocompletion.Package manager research
preinstall,postinstall, etc.)--ignore-scriptsOnly npm has meaningful pre/post install scripts among the supported runtimes, so
--ignore-scriptsis the only relevant flag.Tests
pkg/workflow/run_install_scripts_validation_test.go— new file with comprehensive unit testsclaude_engine_test.goandengine_includes_test.goto expect--ignore-scripts