Repository navigation
fix(codeql): harden public-surface validation #59
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
71ed1a3
fix(codeql): remove public-surface regex backtracking
ohbus 6fa72f9
docs(OPS-33): record initial alert triage
ohbus 5dc3056
test(bff): cover cookie GraphQL CSRF boundary
ohbus cdbc0b9
docs(OPS-33): record BFF CSRF triage
ohbus 2c3ad70
fix(codeql): close hosted review findings
ohbus 9fd317d
docs(tasks): record codeql review follow-up
ohbus 0bf0e1b
test(codeql): make regex subprocess assertion explicit
ohbus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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,41 @@ | ||
| """Regression tests for public-surface parsing boundaries.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import subprocess | ||
| import sys | ||
| import unittest | ||
|
|
||
| from tools.contracts.validate_public_surface import GRAPHQL_RESOLVER | ||
|
|
||
|
|
||
| class PublicSurfacePatternTest(unittest.TestCase): | ||
| """Protect GraphQL resolver discovery from ambiguous whitespace matching.""" | ||
|
|
||
| def test_resolver_pattern_accepts_multiline_annotations(self) -> None: | ||
| """Resolver annotations may be separated from functions by blank lines.""" | ||
| source = "@QueryMapping\n\n fun groups" | ||
| self.assertEqual(GRAPHQL_RESOLVER.findall(source), [("Query", "groups")]) | ||
|
|
||
| def test_resolver_pattern_rejects_non_resolver_text(self) -> None: | ||
| """A long newline-only gap without a function must not match.""" | ||
| source = "@QueryMapping\n" + ("\n" * 1024) + "not_a_function" | ||
| self.assertEqual(GRAPHQL_RESOLVER.findall(source), []) | ||
|
|
||
| def test_resolver_pattern_rejects_long_space_run_within_timeout(self) -> None: | ||
| """A nonmatch with long horizontal whitespace must remain bounded.""" | ||
| source = "@QueryMapping\n" + (" " * 32_000) + "not_a_function" | ||
| script = ( | ||
| "import sys; " | ||
| "from tools.contracts.validate_public_surface import GRAPHQL_RESOLVER; " | ||
| "raise SystemExit(bool(GRAPHQL_RESOLVER.findall(sys.argv[1])))" | ||
| ) | ||
| subprocess.run( | ||
| [sys.executable, "-c", script, source], | ||
| check=True, | ||
| timeout=2.0, | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new public test method lacks the structured KDoc required by
AGENTS.mdfor all public methods. Add a/** ... */comment documenting the trusted-origin, access-cookie, and missing-CSRF-proof scenario and the expected rejection before downstream execution; the descriptive test name does not satisfy the explicitly required documentation format.AGENTS.md reference: AGENTS.md:L202-L205
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chatgpt-codex-connector Added structured KDoc to the cookie-authenticated GraphQL transport tests in
2c3ad703. The focused BFF transport test passed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To use Codex here, create an environment for this repo.