|
1 | 1 | K9! |
2 | 2 | # SPDX-License-Identifier: PMPL-1.0-or-later |
3 | | -# K9 Hunt-level template: Full execution with Just recipes |
4 | | -# Security Level: Hunt (full system access) |
5 | | -# ⚠️ SIGNATURE REQUIRED - Review carefully before use |
6 | | - |
7 | | -{ |
8 | | - pedigree = { |
9 | | - schema_version = "1.0.0", |
10 | | - component_type = "TODO: describe component type (e.g., 'deployment', 'setup-script')", |
11 | | - security = { |
12 | | - leash = 'Hunt, |
13 | | - trust_level = "full-system-access", |
14 | | - allow_network = true, |
15 | | - allow_filesystem_write = true, |
16 | | - allow_subprocess = true, |
17 | | - signature_required = true, |
18 | | - }, |
19 | | - metadata = { |
20 | | - name = "TODO: component-name", |
21 | | - version = "1.0.0", |
22 | | - description = "TODO: Detailed description of what this component does", |
23 | | - author = "Jonathan D.A. Jewell <jonathan.jewell@open.ac.uk>", |
24 | | - }, |
25 | | - warnings = [ |
26 | | - "This component has full system access", |
27 | | - "Only run from trusted sources with verified signatures", |
28 | | - "Review all Just recipes before execution", |
29 | | - "Use dry-run mode first: ./must --dry-run run your-file.k9.ncl", |
30 | | - ], |
31 | | - side_effects = [ |
32 | | - "TODO: List what files/directories this creates or modifies", |
33 | | - "TODO: List what commands this executes", |
34 | | - "TODO: List what network access this requires", |
35 | | - ], |
36 | | - }, |
37 | | - |
38 | | - # Configuration with contracts (Yard-level validation) |
39 | | - config = { |
40 | | - # Add your configuration here with appropriate contracts |
41 | | - target_dir |
42 | | - | String |
43 | | - | std.string.NonEmpty |
44 | | - = "/tmp/k9-output", |
45 | | - |
46 | | - dry_run | Bool = false, |
47 | | - |
48 | | - # Add more config as needed |
49 | | - }, |
50 | | - |
51 | | - # Just recipes for execution |
52 | | - # These run when: ./must run your-file.k9.ncl |
53 | | - recipes = { |
54 | | - # Main entry point (runs by default) |
55 | | - default = { |
56 | | - recipe = "TODO: main-task", |
57 | | - description = "TODO: What the default recipe does", |
58 | | - }, |
59 | | - |
60 | | - # Define your recipes here |
61 | | - "main-task" = { |
62 | | - dependencies = ["check-prerequisites"], |
63 | | - commands = [ |
64 | | - "echo 'TODO: Add your commands here'", |
65 | | - # Example: Create directory |
66 | | - # "mkdir -p %{config.target_dir}", |
67 | | - # Example: Run a command |
68 | | - # "just build", |
69 | | - # Example: Conditional execution |
70 | | - # "@if [ \"%{config.dry_run}\" = \"true\" ]; then echo '[DRY-RUN] Would execute'; else actual-command; fi", |
71 | | - ], |
72 | | - }, |
73 | | - |
74 | | - "check-prerequisites" = { |
75 | | - description = "Verify required tools and permissions", |
76 | | - commands = [ |
77 | | - # Example: Check for required tools |
78 | | - # "command -v git || (echo 'ERROR: git not found' && exit 1)", |
79 | | - # Example: Check permissions |
80 | | - # "[ -w %{config.target_dir} ] || (echo 'ERROR: Cannot write to target directory' && exit 1)", |
81 | | - "echo '✓ Prerequisites checked'", |
82 | | - ], |
83 | | - }, |
84 | | - |
85 | | - # Add more recipes as needed |
86 | | - "build" = { |
87 | | - description = "Build the project", |
88 | | - commands = [ |
89 | | - "echo 'TODO: Add build commands'", |
90 | | - ], |
91 | | - }, |
| 3 | +# Robodog-ECM — Template Hunt (K9/Nickel). |
| 4 | +# |
| 5 | +# This component defines the formal strategy for "Hunting" — |
| 6 | +//! automated reconnaissance and dependency discovery within the |
| 7 | +//! electronic countermeasure ecosystem. |
92 | 8 |
|
93 | | - "deploy" = { |
94 | | - description = "Deploy the application", |
95 | | - dependencies = ["build"], |
96 | | - commands = [ |
97 | | - "echo 'TODO: Add deployment commands'", |
98 | | - ], |
99 | | - }, |
| 9 | +leash = 'Kennel # Combined evaluation and execution monitoring. |
100 | 10 |
|
101 | | - "clean" = { |
102 | | - description = "Clean up generated files", |
103 | | - commands = [ |
104 | | - "echo '⚠️ This will delete files - waiting 3 seconds...'", |
105 | | - "sleep 3", |
106 | | - "echo 'TODO: Add cleanup commands'", |
107 | | - # "rm -rf %{config.target_dir}", |
108 | | - ], |
109 | | - }, |
110 | | - }, |
| 11 | +pedigree = { |
| 12 | + schema_version = "1.0.0", |
| 13 | + component_type = "recon-strategy", |
| 14 | + description = "Defines the search patterns for dependency-based vulnerability hunting.", |
| 15 | +} |
111 | 16 |
|
112 | | - # Validation (Yard-level checks before Hunt execution) |
113 | | - validation = { |
114 | | - check_target_dir = std.string.length config.target_dir > 0, |
115 | | - # Add more validation as needed |
116 | | - }, |
| 17 | +# SEARCH PATTERNS: Defines the identifiers and markers to look for. |
| 18 | +patterns = { |
| 19 | + # CRITICAL: Detect usage of deprecated or insecure crypto primitives. |
| 20 | + insecure_crypto = [ |
| 21 | + "md5", "sha1", "des", "rc4", |
| 22 | + ], |
| 23 | + # POLICY: Find instances of non-standard FFI boundaries. |
| 24 | + unverified_ffi = [ |
| 25 | + "extern \"C\"", "unsafe", |
| 26 | + ], |
117 | 27 | } |
118 | 28 |
|
119 | | -# Usage: |
120 | | -# 1. Fill in TODO items above |
121 | | -# 2. Define configuration with contracts |
122 | | -# 3. Implement Just recipes with your commands |
123 | | -# 4. Test with dry-run: ./must --dry-run run your-file.k9.ncl |
124 | | -# 5. Review dry-run output carefully |
125 | | -# 6. Sign the component: ./must sign your-file.k9.ncl |
126 | | -# 7. Distribute with signature: your-file.k9.ncl.sig |
127 | | -# 8. Users verify and run: ./must verify && ./must run your-file.k9.ncl |
128 | | -# |
129 | | -# Security checklist: |
130 | | -# ✓ All TODO items filled in |
131 | | -# ✓ side_effects documented accurately |
132 | | -# ✓ Commands reviewed for safety |
133 | | -# ✓ No hardcoded secrets or credentials |
134 | | -# ✓ Proper error handling in recipes |
135 | | -# ✓ Tested in dry-run mode |
136 | | -# ✓ Component signed with trusted key |
| 29 | +# EXECUTION HOOKS: Procedures to run when a pattern is matched. |
| 30 | +hooks = { |
| 31 | + on_match = fun match_context => |
| 32 | + let severity = if std.array.contains match_context.pattern patterns.insecure_crypto then 'Critical else 'Warning in |
| 33 | + { |
| 34 | + action = 'Flag, |
| 35 | + severity = severity, |
| 36 | + message = "Pattern '%{match_context.pattern}' detected in %{match_context.file}", |
| 37 | + } |
| 38 | +} |
0 commit comments