@jalaxy33/pi-permission 0.0.0-stage → 0.4.0

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.
@@ -0,0 +1,83 @@
1
+ {
2
+ "$schema": "../../schema.json",
3
+ "description": "Bulk or hard-to-recover deletes.",
4
+ "commands": {
5
+ "ask": [
6
+ {
7
+ "id": "rm-recursive",
8
+ "program": "rm",
9
+ "anyFlag": [
10
+ "-r",
11
+ "-R",
12
+ "--recursive"
13
+ ],
14
+ "reason": "recursive delete"
15
+ },
16
+ {
17
+ "id": "find-delete",
18
+ "program": "find",
19
+ "anyFlag": [
20
+ "-delete"
21
+ ],
22
+ "reason": "bulk delete via find"
23
+ },
24
+ {
25
+ "id": "find-exec-rm",
26
+ "program": "find",
27
+ "argvRegex": "-exec\\s+rm\\b",
28
+ "reason": "bulk delete via find -exec rm"
29
+ },
30
+ {
31
+ "id": "xargs-rm",
32
+ "program": "xargs",
33
+ "argvRegex": "(^|\\s)rm(\\s|$)",
34
+ "reason": "bulk delete via xargs"
35
+ },
36
+ {
37
+ "id": "truncate-zero",
38
+ "program": "truncate",
39
+ "argvRegex": "-s\\s*0|--size[= ]0",
40
+ "reason": "truncates a file"
41
+ },
42
+ {
43
+ "id": "rsync-delete",
44
+ "program": "rsync",
45
+ "anyFlag": [
46
+ "--delete",
47
+ "--delete-after"
48
+ ],
49
+ "reason": "deletes destination files"
50
+ },
51
+ {
52
+ "id": "git-clean",
53
+ "program": "git",
54
+ "anyFlag": [
55
+ "-f",
56
+ "--force"
57
+ ],
58
+ "reason": "deletes untracked files",
59
+ "subcommand": [
60
+ "clean"
61
+ ]
62
+ },
63
+ {
64
+ "id": "git-stash-drop",
65
+ "program": "git",
66
+ "argvRegex": "(^|\\s)(drop|clear)(\\s|$)",
67
+ "reason": "deletes a stash",
68
+ "subcommand": [
69
+ "stash"
70
+ ]
71
+ },
72
+ {
73
+ "id": "git-worktree-remove",
74
+ "program": "git",
75
+ "argvRegex": "(^|\\s)remove(\\s|$)",
76
+ "reason": "removes a worktree",
77
+ "subcommand": [
78
+ "worktree"
79
+ ]
80
+ }
81
+ ]
82
+ }
83
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "$schema": "../../schema.json",
3
+ "description": "Database drops and flushes.",
4
+ "commands": {
5
+ "ask": [
6
+ {
7
+ "id": "dropdb",
8
+ "program": "dropdb",
9
+ "reason": "drops a database"
10
+ },
11
+ {
12
+ "id": "sql-drop",
13
+ "program": [
14
+ "psql",
15
+ "mysql",
16
+ "mariadb",
17
+ "sqlite3"
18
+ ],
19
+ "argvRegex": "([Dd][Rr][Oo][Pp]|[Tt][Rr][Uu][Nn][Cc][Aa][Tt][Ee])\\s+([Dd][Aa][Tt][Aa][Bb][Aa][Ss][Ee]|[Tt][Aa][Bb][Ll][Ee]|[Ss][Cc][Hh][Ee][Mm][Aa]|[Ii][Nn][Dd][Ee][Xx]|[Kk][Ee][Yy][Ss][Pp][Aa][Cc][Ee])",
20
+ "reason": "drops or truncates database objects"
21
+ },
22
+ {
23
+ "id": "redis-flush",
24
+ "program": "redis-cli",
25
+ "argvRegex": "[Ff][Ll][Uu][Ss][Hh]([Aa][Ll][Ll]|[Dd][Bb])",
26
+ "reason": "flushes the database"
27
+ }
28
+ ]
29
+ }
30
+ }
@@ -0,0 +1,81 @@
1
+ {
2
+ "$schema": "../../schema.json",
3
+ "description": "Local git state changes that discard work.",
4
+ "commands": {
5
+ "ask": [
6
+ {
7
+ "id": "git-add",
8
+ "program": "git",
9
+ "reason": "stages changes",
10
+ "subcommand": [
11
+ "add"
12
+ ]
13
+ },
14
+ {
15
+ "id": "git-commit",
16
+ "program": "git",
17
+ "reason": "creates a commit",
18
+ "subcommand": [
19
+ "commit"
20
+ ]
21
+ },
22
+ {
23
+ "id": "git-merge",
24
+ "program": "git",
25
+ "reason": "merges branches",
26
+ "subcommand": [
27
+ "merge"
28
+ ]
29
+ },
30
+ {
31
+ "id": "git-reset-hard",
32
+ "program": "git",
33
+ "allFlags": [
34
+ "--hard"
35
+ ],
36
+ "reason": "discards uncommitted work",
37
+ "subcommand": [
38
+ "reset"
39
+ ]
40
+ },
41
+ {
42
+ "id": "git-discard",
43
+ "program": "git",
44
+ "argvRegex": "(^|\\s)(--|\\.|-f|--force)(\\s|$)",
45
+ "unlessFlag": [
46
+ "--staged",
47
+ "-p",
48
+ "--patch"
49
+ ],
50
+ "reason": "discards local changes",
51
+ "subcommand": [
52
+ "checkout",
53
+ "restore"
54
+ ]
55
+ },
56
+ {
57
+ "id": "git-branch-delete",
58
+ "program": "git",
59
+ "anyFlag": [
60
+ "-D"
61
+ ],
62
+ "reason": "deletes a branch",
63
+ "subcommand": [
64
+ "branch"
65
+ ]
66
+ },
67
+ {
68
+ "id": "git-tag-delete",
69
+ "program": "git",
70
+ "anyFlag": [
71
+ "-d",
72
+ "--delete"
73
+ ],
74
+ "reason": "deletes a tag",
75
+ "subcommand": [
76
+ "tag"
77
+ ]
78
+ }
79
+ ]
80
+ }
81
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "$schema": "../../schema.json",
3
+ "description": "Writes to a remote.",
4
+ "commands": {
5
+ "ask": [
6
+ {
7
+ "id": "git-push",
8
+ "program": "git",
9
+ "reason": "updates the remote",
10
+ "subcommand": [
11
+ "push"
12
+ ]
13
+ }
14
+ ],
15
+ "allow": [
16
+ {
17
+ "id": "git-push-lease",
18
+ "program": "git",
19
+ "argvRegex": "--force-with-lease",
20
+ "reason": "force-with-lease is recoverable",
21
+ "subcommand": [
22
+ "push"
23
+ ]
24
+ }
25
+ ]
26
+ }
27
+ }
@@ -0,0 +1,45 @@
1
+ {
2
+ "$schema": "../../schema.json",
3
+ "description": "Infrastructure and container state changes.",
4
+ "commands": {
5
+ "ask": [
6
+ {
7
+ "id": "terraform-apply",
8
+ "program": "terraform",
9
+ "args": [
10
+ "apply",
11
+ "destroy"
12
+ ],
13
+ "reason": "changes infrastructure"
14
+ },
15
+ {
16
+ "id": "kubectl-destructive",
17
+ "program": "kubectl",
18
+ "args": [
19
+ "delete",
20
+ "drain"
21
+ ],
22
+ "reason": "deletes cluster resources"
23
+ },
24
+ {
25
+ "id": "helm-uninstall",
26
+ "program": "helm",
27
+ "args": [
28
+ "uninstall",
29
+ "delete"
30
+ ],
31
+ "reason": "uninstalls a release"
32
+ },
33
+ {
34
+ "id": "docker-prune",
35
+ "program": [
36
+ "docker",
37
+ "podman",
38
+ "nerdctl"
39
+ ],
40
+ "argvRegex": "(system\\s+prune|volume\\s+(rm|prune)|compose\\s+down\\b.*-v)",
41
+ "reason": "removes volumes or prunes"
42
+ }
43
+ ]
44
+ }
45
+ }
@@ -0,0 +1,93 @@
1
+ {
2
+ "$schema": "../../schema.json",
3
+ "description": "Damage that cannot be undone.",
4
+ "commands": {
5
+ "deny": [
6
+ {
7
+ "id": "git-history",
8
+ "program": "git",
9
+ "reason": "rewrites history",
10
+ "terminate": true,
11
+ "subcommand": [
12
+ "filter-branch",
13
+ "filter-repo"
14
+ ]
15
+ },
16
+ {
17
+ "id": "git-update-ref",
18
+ "program": "git",
19
+ "anyFlag": [
20
+ "-d",
21
+ "--delete"
22
+ ],
23
+ "reason": "deletes refs",
24
+ "terminate": true,
25
+ "subcommand": [
26
+ "update-ref"
27
+ ]
28
+ },
29
+ {
30
+ "id": "git-reflog",
31
+ "program": "git",
32
+ "argvRegex": "(^|\\s)(expire|delete)(\\s|$)",
33
+ "reason": "removes the recovery log",
34
+ "terminate": true,
35
+ "subcommand": [
36
+ "reflog"
37
+ ]
38
+ },
39
+ {
40
+ "id": "git-gc-prune",
41
+ "program": "git",
42
+ "argvRegex": "--prune=(now|0|all|never)",
43
+ "reason": "drops unreachable objects for good",
44
+ "terminate": true,
45
+ "subcommand": [
46
+ "gc"
47
+ ]
48
+ }
49
+ ],
50
+ "ask": [
51
+ {
52
+ "id": "dd-write",
53
+ "program": "dd",
54
+ "argvRegex": "(^|\\s)of=",
55
+ "reason": "raw device write"
56
+ },
57
+ {
58
+ "id": "mkfs",
59
+ "program": [
60
+ "mkfs",
61
+ "mkfs.*"
62
+ ],
63
+ "reason": "filesystem format"
64
+ },
65
+ {
66
+ "id": "wipefs",
67
+ "program": "wipefs",
68
+ "reason": "filesystem signature wipe"
69
+ },
70
+ {
71
+ "id": "blkdiscard",
72
+ "program": "blkdiscard",
73
+ "reason": "block device discard"
74
+ },
75
+ {
76
+ "id": "disk-partition",
77
+ "program": [
78
+ "fdisk",
79
+ "cfdisk",
80
+ "sfdisk",
81
+ "parted",
82
+ "sgdisk"
83
+ ],
84
+ "reason": "disk partitioning"
85
+ },
86
+ {
87
+ "id": "shred",
88
+ "program": "shred",
89
+ "reason": "secure file overwrite"
90
+ }
91
+ ]
92
+ }
93
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "$schema": "../../schema.json",
3
+ "description": "Escalation, container escapes and permission-wide changes.",
4
+ "commands": {
5
+ "ask": [
6
+ {
7
+ "id": "sudo",
8
+ "program": [
9
+ "sudo",
10
+ "doas",
11
+ "pkexec"
12
+ ],
13
+ "reason": "privilege escalation"
14
+ },
15
+ {
16
+ "id": "docker-privileged",
17
+ "program": [
18
+ "docker",
19
+ "podman",
20
+ "nerdctl"
21
+ ],
22
+ "args": [
23
+ "run",
24
+ "create"
25
+ ],
26
+ "argvRegex": "--privileged|--pid[= ]host|--network[= ]host|--userns[= ]host|--ipc[= ]host|--uts[= ]host|/var/run/docker.sock|/run/docker.sock",
27
+ "reason": "container escapes the sandbox"
28
+ },
29
+ {
30
+ "id": "chmod-recursive-world",
31
+ "program": "chmod",
32
+ "anyFlag": [
33
+ "-R",
34
+ "--recursive"
35
+ ],
36
+ "argvRegex": "(^|\\s)(777|0777|1777|7777|a\\+rwx|ugo\\+rwx)(\\s|$)",
37
+ "reason": "insecure recursive permissions"
38
+ },
39
+ {
40
+ "id": "chown-recursive",
41
+ "program": "chown",
42
+ "anyFlag": [
43
+ "-R",
44
+ "--recursive"
45
+ ],
46
+ "reason": "recursive ownership change"
47
+ }
48
+ ]
49
+ }
50
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "$schema": "../../schema.json",
3
+ "description": "Packages and remote resources that leave the machine.",
4
+ "commands": {
5
+ "ask": [
6
+ {
7
+ "id": "publish",
8
+ "program": [
9
+ "npm",
10
+ "bun",
11
+ "pnpm",
12
+ "yarn",
13
+ "cargo",
14
+ "gem"
15
+ ],
16
+ "args": [
17
+ "publish",
18
+ "unpublish",
19
+ "push"
20
+ ],
21
+ "reason": "publishes a package"
22
+ },
23
+ {
24
+ "id": "gh-delete",
25
+ "program": "gh",
26
+ "args": [
27
+ "delete"
28
+ ],
29
+ "reason": "deletes a remote resource"
30
+ }
31
+ ]
32
+ }
33
+ }
@@ -0,0 +1,43 @@
1
+ {
2
+ "$schema": "../../schema.json",
3
+ "description": "Credentials that must not reach the agent.",
4
+ "paths": [
5
+ {
6
+ "id": "secrets-env",
7
+ "patterns": [
8
+ ".env",
9
+ ".env.*"
10
+ ],
11
+ "except": [
12
+ ".env.example",
13
+ ".env.sample",
14
+ ".env.test",
15
+ "*.example.env"
16
+ ],
17
+ "action": "deny",
18
+ "ops": [
19
+ "read",
20
+ "write",
21
+ "delete"
22
+ ],
23
+ "message": "pi-permission: .env files hold secrets; ask the user to read or change them"
24
+ },
25
+ {
26
+ "id": "private-keys",
27
+ "patterns": [
28
+ "*.pem",
29
+ "*.key",
30
+ "id_rsa",
31
+ "id_ed25519",
32
+ "id_ecdsa"
33
+ ],
34
+ "except": [
35
+ "*.pub",
36
+ "*.crt",
37
+ "*.csr"
38
+ ],
39
+ "action": "deny",
40
+ "message": "pi-permission: private key material is off limits"
41
+ }
42
+ ]
43
+ }