@f4bioo/berry-shield 2026.3.3-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CONTRIBUTING.md +32 -0
  2. package/LICENSE +201 -0
  3. package/README.md +251 -0
  4. package/SECURITY_AUDIT.md +96 -0
  5. package/docs/wiki/README.md +108 -0
  6. package/docs/wiki/decision/README.md +48 -0
  7. package/docs/wiki/decision/modes.md +176 -0
  8. package/docs/wiki/decision/patterns.md +137 -0
  9. package/docs/wiki/decision/posture.md +68 -0
  10. package/docs/wiki/deploy/README.md +51 -0
  11. package/docs/wiki/deploy/auditing.md +56 -0
  12. package/docs/wiki/deploy/build.md +92 -0
  13. package/docs/wiki/deploy/github-ci-cd.md +107 -0
  14. package/docs/wiki/deploy/installation.md +348 -0
  15. package/docs/wiki/engine/README.md +53 -0
  16. package/docs/wiki/engine/match-engine.md +91 -0
  17. package/docs/wiki/engine/performance.md +114 -0
  18. package/docs/wiki/engine/redaction.md +120 -0
  19. package/docs/wiki/layers/README.md +68 -0
  20. package/docs/wiki/layers/leaf.md +126 -0
  21. package/docs/wiki/layers/pulp.md +139 -0
  22. package/docs/wiki/layers/root.md +130 -0
  23. package/docs/wiki/layers/stem.md +139 -0
  24. package/docs/wiki/layers/thorn.md +139 -0
  25. package/docs/wiki/layers/vine.md +154 -0
  26. package/docs/wiki/operation/README.md +31 -0
  27. package/docs/wiki/operation/cli/README.md +122 -0
  28. package/docs/wiki/operation/cli/add.md +157 -0
  29. package/docs/wiki/operation/cli/help.md +83 -0
  30. package/docs/wiki/operation/cli/init.md +52 -0
  31. package/docs/wiki/operation/cli/list.md +78 -0
  32. package/docs/wiki/operation/cli/mode.md +93 -0
  33. package/docs/wiki/operation/cli/policy.md +202 -0
  34. package/docs/wiki/operation/cli/profile.md +98 -0
  35. package/docs/wiki/operation/cli/remove.md +96 -0
  36. package/docs/wiki/operation/cli/report.md +66 -0
  37. package/docs/wiki/operation/cli/reset.md +99 -0
  38. package/docs/wiki/operation/cli/rules.md +161 -0
  39. package/docs/wiki/operation/cli/status.md +103 -0
  40. package/docs/wiki/operation/cli/test.md +119 -0
  41. package/docs/wiki/operation/cli/toggle.md +90 -0
  42. package/docs/wiki/operation/cli/vine.md +193 -0
  43. package/docs/wiki/operation/web/README.md +27 -0
  44. package/docs/wiki/tutorials/README.md +40 -0
  45. package/docs/wiki/tutorials/audit-to-enforce-rollout.md +99 -0
  46. package/docs/wiki/tutorials/build-custom-rules.md +99 -0
  47. package/docs/wiki/tutorials/choose-profile.md +91 -0
  48. package/docs/wiki/tutorials/incident-triage-report.md +99 -0
  49. package/docs/wiki/tutorials/secure-session.md +115 -0
  50. package/docs/wiki/tutorials/tune-policy.md +111 -0
  51. package/openclaw.plugin.json +293 -0
  52. package/package.json +70 -0
@@ -0,0 +1,119 @@
1
+ ---
2
+ summary: "CLI reference for `openclaw bshield test` (test one input against active match patterns)"
3
+ read_when:
4
+ - You need to verify if a string matches built-in or custom patterns
5
+ - You are validating custom regex behavior before production use
6
+ title: "test"
7
+ ---
8
+
9
+ # `openclaw bshield test`
10
+
11
+ Test one input string against active built-in and custom match patterns.
12
+
13
+ ## What it does
14
+ - Loads built-in secret/PII patterns and custom secret rules.
15
+ - Evaluates the provided input against active patterns.
16
+ - Prints either no-match output or match details with rule source and redaction placeholder.
17
+
18
+ ## Scope and limitation
19
+ - This command validates only:
20
+ - baseline secret and pii patterns
21
+ - custom secret rules
22
+ - This command evaluates enabled rules only.
23
+ - This command does not validate custom command or file rules.
24
+
25
+ ### Inspect file/command rules
26
+ Use this when you need full visibility for custom file and command rules.
27
+ ```bash
28
+ openclaw bshield rules list --detailed
29
+ ```
30
+ Expected: CLI prints full custom and baseline inventory with ID and pattern.
31
+
32
+ ## When to use
33
+ - Validating new custom secret patterns.
34
+ - Debugging false positives or false negatives.
35
+ - Verifying expected redaction placeholder mapping.
36
+
37
+ ## Syntax
38
+
39
+ ### Test one input
40
+ Use this command to evaluate one input string against current match rules.
41
+ ```bash
42
+ openclaw bshield test "<input>"
43
+ ```
44
+ Expected: CLI reports no matches or prints one or more matching rule entries.
45
+
46
+ ## Options
47
+ Positional argument:
48
+ - `<input>`: string to test against active built-in and custom patterns.
49
+
50
+ ## Examples
51
+
52
+ ### Test a string with no expected match
53
+ Use this to validate baseline no-match behavior.
54
+ ```bash
55
+ openclaw bshield test "hello world"
56
+ ```
57
+ Result: CLI reports no matches found.
58
+
59
+ ### Test a token-like string
60
+ Use this to validate secret-pattern detection.
61
+ ```bash
62
+ openclaw bshield test "sk_live_1234567890abcdef123456"
63
+ ```
64
+ Result: CLI reports one or more matches with source and redaction placeholder.
65
+
66
+ ### Test after adding one custom rule
67
+ Use this to verify new custom match behavior.
68
+ ```bash
69
+ openclaw bshield test "MY_CUSTOM_TOKEN_ABC123"
70
+ ```
71
+ Result: CLI reports custom match entry if the pattern is configured correctly.
72
+
73
+ ### Expected no-match for custom command/file strings
74
+ Use this when checking a string that belongs to custom command or file rules.
75
+ ```bash
76
+ openclaw bshield test "SMOKE_WEB_CMD"
77
+ ```
78
+ Expected: `No matches found` because this command does not evaluate custom command/file rules.
79
+
80
+ ### Typed ID input is not a payload value
81
+ Use this when input is a rule ID format.
82
+ ```bash
83
+ openclaw bshield test "command:smoke-web-cmd"
84
+ ```
85
+ Expected: no matches and guidance that typed IDs are rule identifiers, not payload values for this command.
86
+
87
+ ### Confirm command/file rule state
88
+ Use this after the no-match output above.
89
+ Use the detailed list command shown in `Inspect file/command rules`.
90
+ Expected: command and file entries appear with full patterns so you can verify rule exists, is `ENABLED`, and has the expected active pattern.
91
+
92
+ ## Common errors
93
+
94
+ ### Shell quoting issue on input value
95
+ Use this when shell splits the intended input unexpectedly.
96
+ ```bash
97
+ openclaw bshield test sk_live_1234567890abcdef123456
98
+ ```
99
+ Expected: CLI still runs, but testing semantics depend on shell parsing of the input.
100
+
101
+ ### Pattern read failure
102
+ Use this when command output is missing expected custom matches due to storage/runtime issues.
103
+ ```bash
104
+ openclaw bshield test "sample"
105
+ ```
106
+ Expected: On failure, runtime reports storage/read issues for custom rule loading.
107
+
108
+ ## Related commands
109
+ - [index](README.md)
110
+ - [add](add.md)
111
+ - [rules](rules.md)
112
+ - [list](list.md)
113
+ - [remove](remove.md)
114
+
115
+ ---
116
+
117
+ ## Navigation
118
+ - [Back to CLI Index](README.md)
119
+ - [Back to Wiki Index](../../README.md)
@@ -0,0 +1,90 @@
1
+ ---
2
+ summary: "CLI reference for `openclaw bshield toggle` (enable or disable one security layer)"
3
+ read_when:
4
+ - You need to temporarily disable or re-enable one Berry Shield layer
5
+ - You are debugging behavior at layer level
6
+ title: "toggle"
7
+ ---
8
+
9
+ # `openclaw bshield toggle`
10
+
11
+ Toggle one Berry Shield security layer between enabled and disabled states.
12
+
13
+ ## What it does
14
+ - Validates layer name against known layer keys.
15
+ - Reads current layer state (or uses default when config is missing).
16
+ - Writes the inverse state to config.
17
+ - Returns explicit success or failure output.
18
+
19
+ ## When to use
20
+ - Isolated diagnostics for one layer.
21
+ - Controlled troubleshooting in non-production workflows.
22
+ - Temporary layer disable/enable during rule tuning.
23
+
24
+ ## Syntax
25
+
26
+ ### Toggle one layer
27
+ Use this to invert the current state of a selected layer.
28
+ ```bash
29
+ openclaw bshield toggle <layer>
30
+ ```
31
+ Expected: CLI confirms selected layer is now ENABLED or DISABLED.
32
+
33
+ ## Options
34
+ Positional argument:
35
+ - `<layer>`: one of root, pulp, thorn, leaf, stem.
36
+
37
+ ## Examples
38
+
39
+ ### Toggle root layer
40
+ Use this when debugging root policy injection behavior.
41
+ ```bash
42
+ openclaw bshield toggle root
43
+ ```
44
+ Result: Root layer flips state and CLI confirms the new value.
45
+
46
+ ### Toggle stem layer
47
+ Use this when isolating gate behavior during security tests.
48
+ ```bash
49
+ openclaw bshield toggle stem
50
+ ```
51
+ Result: Stem layer flips state and CLI confirms the new value.
52
+
53
+ ### Verify layer states after toggle
54
+ Use this check after any toggle operation.
55
+ ```bash
56
+ openclaw bshield status
57
+ ```
58
+ Result: Security Layers section reflects ACTIVE or OFF for each layer.
59
+
60
+ ## Common errors
61
+
62
+ ### Invalid layer name
63
+ Use this to validate layer allowlist behavior.
64
+ ```bash
65
+ openclaw bshield toggle kernel
66
+ ```
67
+ Expected: CLI fails with message listing available layers.
68
+
69
+ ### Toggle write failure
70
+ Use this when toggle command reports operation failure.
71
+ ```bash
72
+ openclaw bshield toggle leaf
73
+ ```
74
+ Expected: On failure, CLI prints operation failure and returns non-zero exit code.
75
+
76
+ Possible causes:
77
+ - Config write permission issue.
78
+ - Config backend/runtime error.
79
+
80
+ ## Related commands
81
+ - [index](README.md)
82
+ - [status](status.md)
83
+ - [mode](mode.md)
84
+ - [policy](policy.md)
85
+
86
+ ---
87
+
88
+ ## Navigation
89
+ - [Back to CLI Index](README.md)
90
+ - [Back to Wiki Index](../../README.md)
@@ -0,0 +1,193 @@
1
+ ---
2
+ summary: "CLI reference for `openclaw bshield vine` (status, get/set, and allowlist operations)"
3
+ read_when:
4
+ - You need deterministic Berry.Vine tuning for tests or operations
5
+ - You want to inspect or update Vine thresholds without editing JSON manually
6
+ title: "vine"
7
+ ---
8
+
9
+ # `openclaw bshield vine`
10
+
11
+ Manage Berry.Vine configuration and tool allowlist from CLI.
12
+
13
+ ## What it does
14
+ - Prints current Vine configuration (status).
15
+ - Reads Vine values (get).
16
+ - Writes deterministic Vine paths (set).
17
+ - Adds one tool to Vine allowlist (allow).
18
+ - Removes one tool from Vine allowlist (deny).
19
+
20
+ ## When to use
21
+ - Before smoke tests that need strict/balanced Vine behavior.
22
+ - During incident response for false-positive tuning.
23
+ - In scripts where Vine changes must be reproducible.
24
+
25
+ ## Syntax
26
+
27
+ ### Status (default action)
28
+ Use this to print the current effective Vine configuration.
29
+ ```bash
30
+ openclaw bshield vine
31
+ ```
32
+ Expected: CLI prints mode, thresholds, retention, and allowlist count.
33
+
34
+ ### Explicit status
35
+ Use this when you want explicit command intent.
36
+ ```bash
37
+ openclaw bshield vine status
38
+ ```
39
+ Expected: Same output as default action.
40
+
41
+ ### Read values
42
+ Use this to inspect all Vine values or one specific path.
43
+ ```bash
44
+ openclaw bshield vine get [path]
45
+ ```
46
+ Expected: CLI prints all Vine fields or one selected path.
47
+
48
+ ### Update one value
49
+ Use this to update one supported Vine path.
50
+ ```bash
51
+ openclaw bshield vine set <path> <value>
52
+ ```
53
+ Expected: CLI confirms updated path and value.
54
+
55
+ ### Allow one tool
56
+ Use this to exempt one tool from Vine escalation.
57
+ ```bash
58
+ openclaw bshield vine allow <toolName>
59
+ ```
60
+ Expected: Tool name is appended to `vine.toolAllowlist`.
61
+
62
+ ### Deny one tool
63
+ Use this to remove one tool from Vine allowlist.
64
+ ```bash
65
+ openclaw bshield vine deny <toolName>
66
+ ```
67
+ Expected: Tool name is removed from `vine.toolAllowlist`.
68
+
69
+ ## Options
70
+ Actions:
71
+ - status
72
+ - get
73
+ - set
74
+ - allow
75
+ - deny
76
+
77
+ Supported `set` paths:
78
+ - `mode` (`balanced | strict`)
79
+ - `thresholds.externalSignalsToEscalate` (integer `>= 1`)
80
+ - `thresholds.forcedGuardTurns` (integer `>= 1`)
81
+ - `retention.maxEntries` (integer `>= 1`)
82
+ - `retention.ttlSeconds` (integer `>= 1`)
83
+
84
+ ## Tuning guide
85
+
86
+ | Field | Change when | Typical direction | Tradeoff |
87
+ | --- | --- | --- | --- |
88
+ | `mode` | You need stronger or softer protection posture | `balanced -> strict` for harder blocking | `strict` reduces risk but may increase false positives |
89
+ | `thresholds.externalSignalsToEscalate` | Vine escalates too early or too late | Increase to reduce sensitivity, decrease to escalate faster | Lower values improve safety response, higher values reduce noise |
90
+ | `thresholds.forcedGuardTurns` | Guard window is too short or too long after escalation | Increase for stronger persistence, decrease for faster recovery | Higher values improve protection continuity but may impact UX |
91
+ | `retention.maxEntries` | High session churn or memory pressure appears | Decrease on constrained hosts, increase for larger workloads | Lower values save memory, higher values keep more Vine state |
92
+ | `retention.ttlSeconds` | Session risk state expires too fast or remains too long | Increase for longer correlation, decrease for faster cleanup | Longer TTL helps traceability, shorter TTL reduces stale state |
93
+
94
+ ## Allowlist guide
95
+
96
+ ### What allowlist is for
97
+ - Allowlist is an exception list for tool names.
98
+ - If a tool is allowlisted, Vine does not escalate risk based on that tool output.
99
+ - Use this only for tools you trust and control.
100
+
101
+ ### When to use allowlist
102
+ - A known-safe internal tool keeps triggering Vine noise.
103
+ - You need short-term tuning during controlled tests.
104
+ - You validated the tool output path and ownership.
105
+
106
+ ### Risk to understand first
107
+ - Allowlisting reduces Vine coverage for that tool.
108
+ - If the allowlisted tool starts returning risky external content, Vine may not react as expected.
109
+ - Keep the list small and review it often.
110
+
111
+ ### Add one tool
112
+ Use this to create one allowlist exception.
113
+ Use the allow command shown in Syntax with the trusted tool name.
114
+ Expected: selected tool is added to allowlist.
115
+
116
+ ### Check current allowlist state
117
+ Use this to confirm count and current Vine posture.
118
+ Use the explicit status command shown in Syntax.
119
+ Expected: Vine section shows current allowlist count.
120
+
121
+ ### Remove one tool
122
+ Use this to restore normal Vine protection for a tool.
123
+ Use the deny command shown in Syntax with the same tool name previously allowlisted.
124
+ Expected: selected tool is removed from allowlist.
125
+
126
+ ## Examples
127
+
128
+ ### Set strict mode for aggressive blocking
129
+ Use this for high-sensitivity validation runs.
130
+ ```bash
131
+ openclaw bshield vine set mode strict
132
+ ```
133
+ Result: CLI confirms `mode = strict`.
134
+
135
+ ### Reduce guard turns after escalation
136
+ Use this to lower Vine persistence during tuning.
137
+ ```bash
138
+ openclaw bshield vine set thresholds.forcedGuardTurns 2
139
+ ```
140
+ Result: CLI confirms forced guard turns updated.
141
+
142
+ ### Allowlist one tool
143
+ Use this when one trusted tool should not trigger Vine escalation.
144
+ ```bash
145
+ openclaw bshield vine allow web_fetch
146
+ ```
147
+ Result: tool is added to allowlist.
148
+
149
+ ### Remove allowlisted tool
150
+ Use this when previously trusted tool should be guarded again.
151
+ ```bash
152
+ openclaw bshield vine deny web_fetch
153
+ ```
154
+ Result: tool is removed from allowlist.
155
+
156
+ ## See more:
157
+
158
+ - [Vine runtime validation principles](../../layers/vine.md#runtime-validation-principles)
159
+
160
+ ## Common errors
161
+
162
+ ### Invalid action
163
+ Use this check when command fails before execution.
164
+ ```bash
165
+ openclaw bshield vine edit mode strict
166
+ ```
167
+ Expected: CLI fails and prints valid actions.
168
+
169
+ ### Invalid path
170
+ Use this check when deterministic set path is not allowlisted.
171
+ ```bash
172
+ openclaw bshield vine set thresholds.unknown 1
173
+ ```
174
+ Expected: CLI fails and prints allowed Vine paths.
175
+
176
+ ### Invalid value type
177
+ Use this check for numeric/type validation.
178
+ ```bash
179
+ openclaw bshield vine set thresholds.forcedGuardTurns zero
180
+ ```
181
+ Expected: CLI fails with integer validation message.
182
+
183
+ ## Related commands
184
+ - [index](README.md)
185
+ - [status](status.md)
186
+ - [policy](policy.md)
187
+ - [mode](mode.md)
188
+
189
+ ---
190
+
191
+ ## Navigation
192
+ - [Back to CLI Index](README.md)
193
+ - [Back to Wiki Index](../../README.md)
@@ -0,0 +1,27 @@
1
+ ---
2
+ summary: "Web operation reference index for Berry Shield"
3
+ read_when:
4
+ - Defining or documenting Berry Shield behavior in web surfaces
5
+ - Linking future web operation guides
6
+ title: "Web Operation Reference"
7
+ ---
8
+
9
+ # `Web operation reference`
10
+
11
+ This page is reserved for Berry Shield web operation documentation.
12
+
13
+ ## Status
14
+
15
+ Web operation pages are not published yet.
16
+ When web workflows are defined, add pages under this directory.
17
+
18
+ ## Planned topics
19
+ - web configuration workflow
20
+ - web mode/profile/policy editing behavior
21
+ - web verification flows and troubleshooting
22
+
23
+ ---
24
+
25
+ ## Navigation
26
+ - [Back to Operation Index](../README.md)
27
+ - [Back to Wiki Index](../../README.md)
@@ -0,0 +1,40 @@
1
+ ---
2
+ summary: "Tutorial index for step-by-step Berry Shield onboarding flows"
3
+ read_when:
4
+ - You are new to Berry Shield and need guided workflows
5
+ - You want practical command sequences with expected outcomes
6
+ - You need a safe validation flow before production usage
7
+ title: "Tutorials"
8
+ ---
9
+
10
+ # `Tutorials`
11
+
12
+ This section provides practical, step-by-step workflows for Berry Shield.
13
+ Use these pages when you want guided execution rather than command reference.
14
+
15
+ ## Available tutorials
16
+
17
+ - [secure session](secure-session.md): end-to-end first session with verification checkpoints
18
+ - [choose your profile](choose-profile.md): decide strict/balanced/minimal with practical checks
19
+ - [tune policy](tune-policy.md): configure adaptive and retention values safely
20
+ - [build custom rules](build-custom-rules.md): add, test, list, and remove organization-specific rules
21
+ - [audit-to-enforce rollout](audit-to-enforce-rollout.md): move from observation to active mitigation
22
+ - [incident triage with report](incident-triage-report.md): investigate events and close detection gaps
23
+
24
+ ## How tutorials differ from CLI reference
25
+
26
+ - Tutorials focus on outcome-driven flows.
27
+ - CLI reference focuses on command contracts and options.
28
+ - Use tutorials first, then jump to CLI pages for advanced tuning.
29
+
30
+ ## Related pages
31
+ - [operation index](../operation/README.md)
32
+ - [CLI reference](../operation/cli/README.md)
33
+ - [decision modes](../decision/modes.md)
34
+ - [decision posture](../decision/posture.md)
35
+
36
+ ---
37
+
38
+ ## Navigation
39
+ - [Back to Wiki Index](../README.md)
40
+ - [Back to Repository README](../../../README.md)
@@ -0,0 +1,99 @@
1
+ ---
2
+ summary: "Roll out from audit observation to enforce protection safely"
3
+ read_when:
4
+ - You are preparing first production rollout
5
+ - You need controlled transition from audit to enforce
6
+ - You want evidence-driven go/no-go criteria
7
+ title: "Audit-to-Enforce Rollout"
8
+ ---
9
+
10
+ # `Audit-to-Enforce Rollout`
11
+
12
+ This tutorial defines a safe rollout sequence from observation to active protection.
13
+ It reduces rollout risk by using measured checkpoints and explicit validation.
14
+
15
+ ## Prerequisites
16
+
17
+ - Team agreement on target profile and policy values
18
+ - Access to run operational CLI commands during rollout window
19
+ - A chat session where controlled `berry_check` prompts can be executed
20
+
21
+ ## Step 1: Set audit mode for observation
22
+
23
+ Use this command to start in shadow posture before enabling active mitigation.
24
+ ```bash
25
+ openclaw bshield mode audit
26
+ ```
27
+ Expected:
28
+ - CLI confirms audit mode
29
+
30
+ ## Step 2: Clear previous report baseline
31
+
32
+ Use this command to ensure rollout observations are measured from a clean baseline.
33
+ ```bash
34
+ openclaw bshield report --clear
35
+ ```
36
+ Expected:
37
+ - CLI confirms clear count
38
+
39
+ ## Step 3: Generate controlled security activity
40
+
41
+ Use this prompt in chat to trigger a sensitive-path decision without exposing content.
42
+ Example prompt:
43
+ `Run berry_check with operation=read and target=/etc/shadow. Do not read file contents.`
44
+ Expected:
45
+ - Decision is captured as a shadow-style event in audit posture
46
+
47
+ ## Step 4: Inspect audit evidence
48
+
49
+ Use this command to confirm audit observations are persisted and visible.
50
+ ```bash
51
+ openclaw bshield report
52
+ ```
53
+ Expected:
54
+ - Summary and details show new audit-observation decisions
55
+
56
+ ## Step 5: Switch to enforce mode
57
+
58
+ Use this command to activate active mitigation after audit evidence is reviewed.
59
+ ```bash
60
+ openclaw bshield mode enforce
61
+ ```
62
+ Expected:
63
+ - CLI confirms enforce mode
64
+
65
+ ## Step 6: Re-run the same controlled test
66
+
67
+ Use the same prompt in chat to compare behavior under enforce posture.
68
+ Example prompt:
69
+ `Run berry_check with operation=read and target=/etc/shadow. Do not read file contents.`
70
+ Expected:
71
+ - Sensitive read attempt is denied under enforce
72
+
73
+ ## Step 7: Confirm enforce evidence
74
+
75
+ Use this command to verify enforce decisions are now represented in report output.
76
+ ```bash
77
+ openclaw bshield report
78
+ ```
79
+ Expected:
80
+ - New enforce-time decisions appear in summary/details
81
+
82
+ ## Go-live checklist
83
+
84
+ - Profile is the intended one (`status` confirms).
85
+ - Mode is `ENFORCE` after final switch.
86
+ - Controlled denial test behaves as expected.
87
+ - Report evidence is available for post-rollout review.
88
+
89
+ ## Related pages
90
+ - [tutorial index](README.md)
91
+ - [secure session](secure-session.md)
92
+ - [mode command reference](../operation/cli/mode.md)
93
+ - [report command reference](../operation/cli/report.md)
94
+
95
+ ---
96
+
97
+ ## Navigation
98
+ - [Back to Tutorials Index](README.md)
99
+ - [Back to Wiki Index](../README.md)
@@ -0,0 +1,99 @@
1
+ ---
2
+ summary: "Create, validate, and maintain custom rules with safe workflow"
3
+ read_when:
4
+ - You need organization-specific secret/file/command coverage
5
+ - You want to avoid broad or unsafe regex patterns
6
+ - You need a repeatable custom-rule lifecycle
7
+ title: "Build Custom Rules"
8
+ ---
9
+
10
+ # `Build Custom Rules`
11
+
12
+ This tutorial shows a full custom-rule lifecycle: add, validate, list, and remove.
13
+ Use it to extend built-in coverage for your environment.
14
+
15
+ ## Prerequisites
16
+
17
+ - Berry Shield enabled
18
+ - Basic regex familiarity for custom patterns
19
+
20
+ ## Step 1: Add one custom secret rule
21
+
22
+ Use this command to create a deterministic secret pattern entry.
23
+ ```bash
24
+ openclaw bshield add secret --name team_token_rule --pattern "team_tok_[a-z0-9]{16}"
25
+ ```
26
+ Expected:
27
+ - CLI confirms rule was persisted
28
+
29
+ ## Step 2: Validate rule matching behavior
30
+
31
+ Use this command to test whether your custom pattern matches expected sample input.
32
+ ```bash
33
+ openclaw bshield test "team_tok_a1b2c3d4e5f6g7h8"
34
+ ```
35
+ Expected:
36
+ - Output reports a custom rule match
37
+
38
+ ## Step 3: Validate negative sample
39
+
40
+ Use this command to verify non-matching strings do not produce false positives.
41
+ ```bash
42
+ openclaw bshield test "team_token_invalid_shape"
43
+ ```
44
+ Expected:
45
+ - Output reports no match
46
+
47
+ ## Step 4: List active rules
48
+
49
+ Use this command to inspect built-in and custom rule counts and entries.
50
+ ```bash
51
+ openclaw bshield rules list
52
+ ```
53
+ Expected:
54
+ - Rule list includes your custom `team_token_rule` entry
55
+
56
+ ## Step 5: Remove test rule when done
57
+
58
+ Use this command to remove the temporary custom rule after validation.
59
+ ```bash
60
+ openclaw bshield rules remove custom team_token_rule
61
+ ```
62
+ Expected:
63
+ - CLI confirms rule removal
64
+
65
+ ## Step 6: Confirm clean state
66
+
67
+ Use this command to verify the removed rule no longer appears.
68
+ ```bash
69
+ openclaw bshield rules list
70
+ ```
71
+ Expected:
72
+ - `team_token_rule` is absent from custom entries
73
+
74
+ ## Optional: Use wizard for guided creation
75
+
76
+ Use this command when you want prompts, preview loop, and confirmation flow.
77
+ ```bash
78
+ openclaw bshield add
79
+ ```
80
+ Expected:
81
+ - Wizard guides type selection, pattern input, and save decision
82
+
83
+ ## Rule quality checklist
84
+
85
+ - Keep patterns narrow and specific to reduce accidental matches.
86
+ - Validate both positive and negative samples before production use.
87
+ - Use clear rule names that encode source or owner context.
88
+
89
+ ## Related pages
90
+ - [tutorial index](README.md)
91
+ - [add command reference](../operation/cli/add.md)
92
+ - [test command reference](../operation/cli/test.md)
93
+ - [pattern model](../decision/patterns.md)
94
+
95
+ ---
96
+
97
+ ## Navigation
98
+ - [Back to Tutorials Index](README.md)
99
+ - [Back to Wiki Index](../README.md)