Stage 1 flags the living documents a pull request makes stale (no model, nothing sent). Stage 2, on repositories that opt in with drafter: claude, has Claude Code draft the edits in a sandboxed copy of the tree and opens them as a pull request into the feature branch. A monthly pass re-reads the top-level documents against the whole repository. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
ade847ba5b
38 files changed
+4286
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import unittest
|
||||
|
||||
from docs_review.secrets import is_secret_name, redact, scrub_env, secret_values
|
||||
|
||||
|
||||
class SecretNameTest(unittest.TestCase):
|
||||
def test_name_parts(self):
|
||||
for name in ("DOCS_REVIEW_BOT_TOKEN", "ANTHROPIC_API_KEY", "MY_SECRET",
|
||||
"DB_PASSWORD", "GIT_CREDENTIALS", "HTTP_AUTH", "HTTP_AUTHORIZATION", "gitea_token"):
|
||||
self.assertTrue(is_secret_name(name), name)
|
||||
for name in ("PATH", "HOME", "RUNNER_TEMP", "INPUT_DOCS"):
|
||||
self.assertFalse(is_secret_name(name), name)
|
||||
|
||||
def test_token_boundaries(self):
|
||||
for name in ("CLAUDE_CODE_OAUTH_TOKEN", "DB_PASSWORD", "GITEA_AUTH_TOKEN", "AUTH",
|
||||
"PASS", "SMTP_PASS", "PASS_FILE", "MYSQL_PASSWD", "OAUTH_CLIENT"):
|
||||
self.assertTrue(is_secret_name(name), name)
|
||||
for name in ("GIT_AUTHOR_NAME", "GIT_AUTHOR_EMAIL", "SSH_AUTH_SOCK", "COMPASS_HOME",
|
||||
"GIT_CONFIG_KEY_0", "GIT_CONFIG_VALUE_0", "GIT_CONFIG_COUNT",
|
||||
"AUTHORITY"):
|
||||
self.assertFalse(is_secret_name(name), name)
|
||||
|
||||
def test_scrub_env_keeps_git_config_and_author(self):
|
||||
env = {"GIT_CONFIG_COUNT": "1", "GIT_CONFIG_KEY_0": "safe.directory",
|
||||
"GIT_CONFIG_VALUE_0": "*", "GIT_AUTHOR_NAME": "Bot", "GITEA_AUTH_TOKEN": "t"}
|
||||
self.assertEqual(set(scrub_env(env)), set(env) - {"GITEA_AUTH_TOKEN"})
|
||||
|
||||
|
||||
class RedactTest(unittest.TestCase):
|
||||
def test_replaces_each_secret_value(self):
|
||||
env = {"BOT_TOKEN": "abcdefgh1234", "DB_PASS": "hunter2hunter2", "PATH": "/usr/bin"}
|
||||
out = redact("t=abcdefgh1234 p=hunter2hunter2 path=/usr/bin", env)
|
||||
self.assertEqual(out, "t=*** p=*** path=/usr/bin")
|
||||
|
||||
def test_short_values_are_left(self):
|
||||
self.assertEqual(redact("abc1234 x", {"A_KEY": "abc1234"}), "abc1234 x")
|
||||
self.assertEqual(secret_values({"A_KEY": "abc1234", "B_KEY": "abcd1234"}),
|
||||
["abcd1234"])
|
||||
|
||||
def test_longest_value_first(self):
|
||||
env = {"A_TOKEN": "abcdefgh", "B_TOKEN": "abcdefghijkl"}
|
||||
self.assertEqual(redact("abcdefghijkl", env), "***")
|
||||
|
||||
def test_scrub_env_drops_secret_names(self):
|
||||
env = {"PATH": "/bin", "X_TOKEN": "v", "GIT_ASKPASS": "a", "HOME": "/h"}
|
||||
self.assertEqual(scrub_env(env), {"PATH": "/bin", "HOME": "/h"})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user