Add per-instance safety config with rules, confirm mode, and global safety#318
Merged
Add per-instance safety config with rules, confirm mode, and global safety#318
Conversation
…afety.json
SafetyGuard evaluates operations against rules (allow/block/confirm) and
levels. Rules match by HTTP method+path, job ID, or CLI command ID with
glob patterns. Confirmation mode softens blocks into interactive prompts.
Global safety config loaded from {configDir}/safety.json or SFCC_SAFETY_CONFIG
env var. Merges with per-instance dw.json: level uses max, confirm uses OR,
instance rules take priority over global rules.
When a job export or import passes safety evaluation, the subsequent WebDAV DELETE (archive cleanup) was still caught by the HTTP middleware's level check. Now the commands add a temporary rule allowing DELETE on Impex paths for the duration of the operation. Also adds SafetyGuard.temporarilyAddRule() for arbitrary temporary rules.
…und operations
- Evaluate command rules in BaseCommand.init() so every command is checked
against safety rules automatically (e.g., { command: "code:deploy", action: "block" })
- Add temporary DELETE allow rules for code:deploy and code:watch to prevent
internal WebDAV cleanup from being blocked by safety middleware
- Simplify job commands to only evaluate job-specific rules (command rules
now handled generically)
- Update safety guide to document automatic command rule enforcement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
confirm: true) softens level-based blocks into interactive prompts; non-interactive environments (MCP, CI) block insteadsafetyobject in dw.json with level, confirm, and rules{configDir}/safety.jsonorSFCC_SAFETY_CONFIGenv var — merges with per-instance (level: max wins, confirm: OR, instance rules checked first)withSafetyConfirmationutility for retry-after-confirm pattern (used by CLI, available for VS Code extension and SDK consumers)job:run,job:import,job:export) evaluate both job and command safety rules before execution/guide/safetyTest plan
safetyrules — verify blocking, allowing, confirming behaviorsafety.jsonin config dir — verify global rules merge with per-instanceSFCC_SAFETY_CONFIGenv var — verify override of global config pathSFCC_SAFETY_LEVELenv var still works when no config safety present