feat: add SQL/SQLite, AppSec, Capstone incident-tracker, Gitea Actions CI and spaced repetition
Test and Lint / quality (push) Successful in 34s
Test and Lint / quality (push) Successful in 34s
This commit is contained in:
1 parent
0ac80d60d4
commit
9430a194c3
18 files changed
+422
-7
No files matched your search
@@ -0,0 +1,24 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from appsec import PathTraversalError, redact_secrets, safe_join
|
||||
|
||||
|
||||
def test_safe_join_allows_nested_and_blocks_traversal(tmp_path: Path) -> None:
|
||||
ok = safe_join(tmp_path, "configs/app.yaml")
|
||||
assert ok == (tmp_path / "configs" / "app.yaml").resolve()
|
||||
|
||||
with pytest.raises(PathTraversalError):
|
||||
safe_join(tmp_path, "../../etc/passwd")
|
||||
|
||||
with pytest.raises(PathTraversalError):
|
||||
safe_join(tmp_path, "/etc/passwd")
|
||||
|
||||
|
||||
def test_redact_secrets_masks_credentials() -> None:
|
||||
line = "auth failed header=Bearer s3cr3tTok3n user=admin password=hunter2 token=abc_123"
|
||||
cleaned = redact_secrets(line)
|
||||
assert "s3cr3tTok3n" not in cleaned
|
||||
assert "hunter2" not in cleaned
|
||||
assert "abc_123" not in cleaned
|
||||
assert "user=admin" in cleaned
|
||||
Reference in new issue
Block a user