Skip to content

Commit 7c9f885

Browse files
committed
Move log directory to .github/, revert hook files back to
hooks/ - Revert hook files from .github/hooks/ back to hooks/tool-guardian/ - Update default log path to .github/logs/copilot/tool-guardian/ - Update all path references in README.md and hooks.json
1 parent 3574688 commit 7c9f885

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,20 @@ AI coding agents can autonomously execute shell commands, file operations, and d
3333
1. Copy the hook folder to your repository:
3434

3535
```bash
36-
cp -r .github/hooks/tool-guardian your-repo/.github/hooks/
36+
cp -r hooks/tool-guardian your-repo/hooks/
3737
```
3838

3939
2. Ensure the script is executable:
4040

4141
```bash
42-
chmod +x .github/hooks/tool-guardian/guard-tool.sh
42+
chmod +x hooks/tool-guardian/guard-tool.sh
4343
```
4444

4545
3. Create the logs directory and add it to `.gitignore`:
4646

4747
```bash
48-
mkdir -p logs/copilot/tool-guardian
49-
echo "logs/" >> .gitignore
48+
mkdir -p .github/logs/copilot/tool-guardian
49+
echo ".github/logs/" >> .gitignore
5050
```
5151

5252
4. Commit the hook configuration to your repository's default branch.
@@ -62,7 +62,7 @@ The hook is configured in `hooks.json` to run on the `preToolUse` event:
6262
"preToolUse": [
6363
{
6464
"type": "command",
65-
"bash": ".github/hooks/tool-guardian/guard-tool.sh",
65+
"bash": "hooks/tool-guardian/guard-tool.sh",
6666
"cwd": ".",
6767
"env": {
6868
"GUARD_MODE": "block"
@@ -80,7 +80,7 @@ The hook is configured in `hooks.json` to run on the `preToolUse` event:
8080
|----------|--------|---------|-------------|
8181
| `GUARD_MODE` | `warn`, `block` | `block` | `warn` logs threats only; `block` exits non-zero to prevent tool execution |
8282
| `SKIP_TOOL_GUARD` | `true` | unset | Disable the guardian entirely |
83-
| `TOOL_GUARD_LOG_DIR` | path | `logs/copilot/tool-guardian` | Directory where guard logs are written |
83+
| `TOOL_GUARD_LOG_DIR` | path | `.github/logs/copilot/tool-guardian` | Directory where guard logs are written |
8484
| `TOOL_GUARD_ALLOWLIST` | comma-separated | unset | Patterns to skip (e.g., `git push --force,npm publish`) |
8585

8686
## How It Works
@@ -110,14 +110,14 @@ The hook is configured in `hooks.json` to run on the `preToolUse` event:
110110
### Safe command (exit 0)
111111

112112
```bash
113-
echo '{"toolName":"bash","toolInput":"git status"}' | bash .github/hooks/tool-guardian/guard-tool.sh
113+
echo '{"toolName":"bash","toolInput":"git status"}' | bash hooks/tool-guardian/guard-tool.sh
114114
```
115115

116116
### Blocked command (exit 1)
117117

118118
```bash
119119
echo '{"toolName":"bash","toolInput":"git push --force origin main"}' | \
120-
GUARD_MODE=block bash .github/hooks/tool-guardian/guard-tool.sh
120+
GUARD_MODE=block bash hooks/tool-guardian/guard-tool.sh
121121
```
122122

123123
```
@@ -135,19 +135,19 @@ echo '{"toolName":"bash","toolInput":"git push --force origin main"}' | \
135135

136136
```bash
137137
echo '{"toolName":"bash","toolInput":"rm -rf /"}' | \
138-
GUARD_MODE=warn bash .github/hooks/tool-guardian/guard-tool.sh
138+
GUARD_MODE=warn bash hooks/tool-guardian/guard-tool.sh
139139
```
140140

141141
### Allowlisted command (exit 0)
142142

143143
```bash
144144
echo '{"toolName":"bash","toolInput":"git push --force origin main"}' | \
145-
TOOL_GUARD_ALLOWLIST="git push --force" bash .github/hooks/tool-guardian/guard-tool.sh
145+
TOOL_GUARD_ALLOWLIST="git push --force" bash hooks/tool-guardian/guard-tool.sh
146146
```
147147

148148
## Log Format
149149

150-
Guard events are written to `logs/copilot/tool-guardian/guard.log` in JSON Lines format:
150+
Guard events are written to `.github/logs/copilot/tool-guardian/guard.log` in JSON Lines format:
151151

152152
```json
153153
{"timestamp":"2026-03-16T10:30:00Z","event":"threats_detected","mode":"block","tool":"bash","threat_count":1,"threats":[{"category":"destructive_git_ops","severity":"critical","match":"git push --force origin main","suggestion":"Use 'git push --force-with-lease' or push to a feature branch"}]}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fi
2525
INPUT=$(cat)
2626

2727
MODE="${GUARD_MODE:-block}"
28-
LOG_DIR="${TOOL_GUARD_LOG_DIR:-logs/copilot/tool-guardian}"
28+
LOG_DIR="${TOOL_GUARD_LOG_DIR:-.github/logs/copilot/tool-guardian}"
2929
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
3030

3131
mkdir -p "$LOG_DIR"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"preToolUse": [
55
{
66
"type": "command",
7-
"bash": ".github/hooks/tool-guardian/guard-tool.sh",
7+
"bash": "hooks/tool-guardian/guard-tool.sh",
88
"cwd": ".",
99
"env": {
1010
"GUARD_MODE": "block"

0 commit comments

Comments
 (0)