Repository navigation
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| { | ||
| "total": 10, | ||
| "unguarded_count": 8, | ||
| "note": "Heuristic static audit of Surypus source. Routes reported as unguarded are candidates for manual review, not confirmed vulnerabilities; login/health and publicPaths are expected false positives.", | ||
| "unguarded": [ | ||
| { | ||
| "route": "/api/v1/login", | ||
| "file": "Middleware.hs", | ||
| "line": 41 | ||
| }, | ||
| { | ||
| "route": "/api/v1/", | ||
| "file": "Authorization.hs", | ||
| "line": 103 | ||
| }, | ||
| { | ||
| "route": "/api/v1/health", | ||
| "file": "Server.hs", | ||
| "line": 213 | ||
| }, | ||
| { | ||
| "route": "/api/v1/health/db", | ||
| "file": "Server.hs", | ||
| "line": 215 | ||
| }, | ||
| { | ||
| "route": "/api/v1/reports/download/", | ||
| "file": "Server.hs", | ||
| "line": 222 | ||
| }, | ||
| { | ||
| "route": "/api/v1/reports/download/", | ||
| "file": "Server.hs", | ||
| "line": 224 | ||
| }, | ||
| { | ||
| "route": "/api/v1/metrics", | ||
| "file": "Server.hs", | ||
| "line": 230 | ||
| }, | ||
| { | ||
| "route": "/api/v1/reports/download/", | ||
| "file": "Server.hs", | ||
| "line": 679 | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| @prefix skos: <http://www.w3.org/2004/02/skos/core#> . | ||
| @prefix ex: <https://new.allunity.ru/vocab/> . | ||
|
|
||
| ex:MaterialType a skos:ConceptScheme ; | ||
| skos:prefLabel "NeoAllUnity material types"@en . | ||
|
|
||
| ex:primary_source a skos:Concept ; skos:inScheme ex:MaterialType ; | ||
| skos:prefLabel "Primary source"@en ; skos:definition "Immutable source material"@en . | ||
| ex:author_text a skos:Concept ; skos:inScheme ex:MaterialType ; | ||
| skos:prefLabel "Author text"@en . | ||
| ex:translation a skos:Concept ; skos:inScheme ex:MaterialType ; | ||
| skos:prefLabel "Translation"@en ; skos:broader ex:author_text . | ||
| ex:commentary a skos:Concept ; skos:inScheme ex:MaterialType ; | ||
| skos:prefLabel "Commentary"@en ; skos:broader ex:author_text . | ||
| ex:media a skos:Concept ; skos:inScheme ex:MaterialType ; | 8000||
| skos:prefLabel "Media"@en . | ||
|
|
||
| ex:relatedTo a skos:Concept ; skos:inScheme ex:MaterialType ; | ||
| skos:prefLabel "related to"@en ; | ||
| skos:definition "Links source, translation and commentary records"@en . |
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #!/usr/bin/env python3 | ||
| """SUR-004 advisory audit: find API routes with no permission check nearby. | ||
|
|
||
| This is a static heuristic, not a proof of safety. It produces evidence for a | ||
| manual review and fails only when a route has neither a permission call nor an | ||
| explicit public-path annotation within the lookahead window. | ||
| """ | ||
| import json | ||
| import re | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| ROUTE = re.compile(r'"(/api/[^"]+)"') | ||
| GUARD = re.compile(r'(requirePermission|checkPermission|authorize|publicPaths|publicPath)', re.I) | ||
|
|
||
|
|
||
| def audit_file(path: Path, lookahead: int = 20): | ||
| lines = path.read_text(encoding="utf-8", errors="replace").splitlines() | ||
| findings = [] | ||
| for i, line in enumerate(lines): | ||
| for route in ROUTE.findall(line): | ||
| window = "\n".join(lines[i + 1:i + 1 + lookahead]) | ||
| guarded = bool(GUARD.search(line) or GUARD.search(window)) | ||
| findings.append({"route": route, "file": str(path), "line": i + 1, | ||
| "guarded": guarded}) | ||
| return findings | ||
|
|
||
|
|
||
| def main(): | ||
| root = Path(sys.argv[1]) if len(sys.argv) > 1 else Path(".") | ||
| files = list(root.rglob("*.hs")) | ||
| findings = [] | ||
| for f in files: | ||
| findings.extend(audit_file(f)) | ||
| unguarded = [f for f in findings if not f["guarded"]] | ||
| out = {"routes": findings, "unguarded": unguarded, | ||
| "total": len(findings), "unguarded_count": len(unguarded)} | ||
| print(json.dumps(out, indent=2, ensure_ascii=False)) | ||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| raise SystemExit(main()) |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| """SUR-004 audit tool tests.""" | ||
| import tempfile | ||
| import unittest | ||
| from pathlib import Path | ||
|
|
||
| from automation.rbac_audit import audit_file | ||
|
|
||
|
|
||
| class TestRbacAudit(unittest.TestCase): | ||
| def test_route_with_permission_is_guarded(self): | ||
| with tempfile.TemporaryDirectory() as d: | ||
| f = Path(d) / "Api.hs" | ||
| f.write_text('handle = get "/api/v1/accounts" $ do\n requirePermission "accounts.read"\n pure ()\n') | ||
| out = audit_file(f) | ||
| self.assertEqual(len(out), 1) | ||
| self.assertTrue(out[0]["guarded"]) | ||
|
|
||
| def test_route_without_permission_is_reported(self): | ||
| with tempfile.TemporaryDirectory() as d: | ||
| f = Path(d) / "Api.hs" | ||
| f.write_text('handle = get "/api/v1/accounts" $ do\n pure []\n') | ||
| out = audit_file(f) | ||
| self.assertFalse(out[0]["guarded"]) | ||
|
|
||
| def test_public_annotation_is_accepted(self): | ||
| with tempfile.TemporaryDirectory() as d: | ||
| f = Path(d) / "Api.hs" | ||
| f.write_text('publicPaths = ["/api/v1/login"]\nget "/api/v1/login" $ pure ()\n') | ||
| self.assertTrue(audit_file(f)[0]["guarded"]) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat: RBAC audit tool and SKOS skeleton #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
feat: RBAC audit tool and SKOS skeleton #12
Changes from all commits
4cc9679File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.