-
Notifications
You must be signed in to change notification settings - Fork 4
Verified Input Sanitizer Safety for #service Payloads and added buttons Field to OrchestrationResponse and TestOrchestrationResponse #367
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
+156
−4
Merged
Changes from all commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
3020e31
Merge pull request #122 from rootcodelabs/wip
nuwangeek 6e5c22c
remove unwanted file
nuwangeek 38d0533
updated changes
nuwangeek 72b8ae1
fixed requested changes
nuwangeek 9b7bc7b
fixed issue
nuwangeek 46dd6c4
Merge pull request #123 from rootcodelabs/llm-316
nuwangeek 068f4e0
Merge pull request #124 from buerokratt/wip
Thirunayan22 a2084e5
service workflow implementation without calling service endpoints
nuwangeek 5216c09
Merge pull request #126 from rootcodelabs/wip
nuwangeek 864ad30
fixed requested changes
nuwangeek 25f9614
fixed issues
nuwangeek 69c1279
protocol related requested changes
nuwangeek 07f2e0f
fixed requested changes
nuwangeek f63f777
update time tracking
nuwangeek 5429bc0
added time tracking and reloacate input guardrail before toolclassifiier
nuwangeek 721263a
fixed issue
nuwangeek 6ed02d1
Merge pull request #127 from buerokratt/wip
nuwangeek 7238baa
Merge branch 'optimization/llm-304' into wip
nuwangeek ae7cfa0
Merge pull request #128 from rootcodelabs/wip
nuwangeek f8a82b6
fixed issue
nuwangeek 3b89fba
added hybrid search for the service detection
nuwangeek 789f062
update tool classifier
nuwangeek 609e6d5
fixing merge conflicts
nuwangeek a30c52d
Merge pull request #129 from buerokratt/wip
nuwangeek 8dfc155
Merge pull request #130 from rootcodelabs/wip
nuwangeek 3d7fb85
updated intent data enrichment and service classification flow perfor…
nuwangeek bee9fbf
fixed issue
nuwangeek 4888045
Merge pull request #131 from rootcodelabs/optimization/data-enrichment
nuwangeek 0a0806f
optimize first user query response generation time
nuwangeek 1eb8b47
fixed pr reviewed issues
nuwangeek 94b4f39
Merge pull request #132 from buerokratt/wip
nuwangeek 82b3fe5
Merge branch 'optimization/vector-indexer' into wip
nuwangeek 1b4ada9
Merge pull request #134 from buerokratt/wip
nuwangeek bb1601f
service integration
nuwangeek 9ce1da2
context based response generation flow
nuwangeek d647f86
fixed pr review suggested issues
nuwangeek d67214e
Merge pull request #135 from rootcodelabs/llm-309
nuwangeek b90ab52
Merge pull request #136 from rootcodelabs/llm-310
nuwangeek 6c46d3c
removed service project layer
nuwangeek d3e1494
fixed issues
nuwangeek 4add446
Merge pull request #137 from rootcodelabs/llm-310
nuwangeek c2ef115
delete unnessary files
nuwangeek 97f6f1a
added requested changes
nuwangeek 0be284e
Merge pull request #138 from buerokratt/wip
nuwangeek a32ca6d
Merge branch 'llm/service-integration' into wip
nuwangeek 4276e7d
Merge pull request #140 from buerokratt/wip
nuwangeek cb1bdc7
validate input sanitizer is compatible with mcq prefixes
nuwangeek 72d2c1f
updated OrchestrationResponse to support buttons field
nuwangeek b2488ba
removed md file
nuwangeek 6e49497
Enhance orchestration logging and update response models for choice b…
nuwangeek 24259a9
Merge pull request #141 from buerokratt/wip
nuwangeek 8ff7ecf
Merge pull request #142 from rootcodelabs/wip
nuwangeek 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,125 @@ | ||
| """Unit tests for InputSanitizer — focused on #service prefix safety. | ||
|
|
||
| Validates that strip_html_tags() and sanitize_message() leave the | ||
| #service, /POST/... routing prefix characters (#, comma, /) untouched, | ||
| so that prefix detection logic in downstream handlers can always match. | ||
| """ | ||
|
|
||
| import pytest | ||
|
|
||
| from src.utils.input_sanitizer import InputSanitizer | ||
|
|
||
|
|
||
| class TestSanitizeMessageServicePrefix: | ||
| """Primary passthrough: #service, /METHOD/... payloads must survive sanitization unchanged.""" | ||
|
|
||
| def test_exact_service_prefix_passthrough(self) -> None: | ||
| """The canonical #service prefix must survive sanitization bit-for-bit identical.""" | ||
| msg = "#service, /POST/services/active/foo" | ||
| assert InputSanitizer.sanitize_message(msg) == msg | ||
|
|
||
| @pytest.mark.parametrize( | ||
| "msg", | ||
| [ | ||
| "#service, /POST/services/active/foo", | ||
| "#service, /GET/services/list", | ||
| "#service, /DELETE/services/active/foo", | ||
| "#service, /PUT/services/active/foo", | ||
| "#service, /PATCH/services/active/foo", | ||
| "#service, /POST/services/active/foo?status=true", | ||
| "#service, /POST/services/active/foo?a=1&b=2", | ||
| "#service, /POST/services/active/foo#anchor", | ||
| ], | ||
| ) | ||
| def test_service_prefix_variants_passthrough(self, msg: str) -> None: | ||
| """All #service, /METHOD/... variants must pass through unmodified.""" | ||
| assert InputSanitizer.sanitize_message(msg) == msg | ||
|
|
||
|
|
||
| class TestSanitizeMessageHtmlStripping: | ||
| """Confirms HTML IS stripped while #service prefix characters survive. | ||
|
|
||
| These tests prove the sanitizer is active (not a no-op) and that it | ||
| surgically removes only HTML constructs, leaving #, comma, and / intact. | ||
| """ | ||
|
|
||
| def test_bold_tags_stripped_prefix_survives(self) -> None: | ||
| result = InputSanitizer.sanitize_message( | ||
| "#service, <b>/POST/</b>services/active/foo" | ||
| ) | ||
| assert result == "#service, /POST/services/active/foo" | ||
|
|
||
| def test_script_tag_content_stripped_path_survives(self) -> None: | ||
| """Dangerous <script> tag and its content are removed; path remainder survives.""" | ||
| result = InputSanitizer.sanitize_message( | ||
| "#service, /POST/<script>alert(1)</script>foo" | ||
| ) | ||
| assert result == "#service, /POST/foo" | ||
|
|
||
| def test_entity_encoded_script_tag_stripped_path_survives(self) -> None: | ||
| """Entity-encoded <script> tag is decoded then stripped; path remainder survives. | ||
|
|
||
| If html.unescape() ran *after* tag stripping, <script>...</script> | ||
| would survive all three stripping passes and be decoded into a live <script> | ||
| tag in the output. The sanitizer must unescape *before* stripping to close | ||
| this bypass. | ||
| """ | ||
| result = InputSanitizer.sanitize_message( | ||
| "#service, /POST/<script>alert(1)</script>foo" | ||
| ) | ||
| assert result == "#service, /POST/foo" | ||
|
|
||
| def test_html_entities_unescaped_prefix_intact(self) -> None: | ||
| """html.unescape() runs inside strip_html_tags(); confirm it does not alter #, comma, or /.""" | ||
| result = InputSanitizer.sanitize_message("#service, /POST/foo&bar") | ||
| assert result == "#service, /POST/foo&bar" | ||
|
|
||
| def test_hash_not_treated_as_html_tag(self) -> None: | ||
| """# is never matched by <[^>]+>; verify it is never stripped.""" | ||
| result = InputSanitizer.sanitize_message("#service, /GET/list") | ||
| assert result.startswith("#service") | ||
|
|
||
| def test_forward_slash_not_stripped(self) -> None: | ||
| """/ characters must survive all three passes of strip_html_tags().""" | ||
| result = InputSanitizer.sanitize_message("#service, /POST/a/b/c") | ||
| assert "/POST/a/b/c" in result | ||
|
|
||
| def test_comma_not_stripped(self) -> None: | ||
| """Comma separator between prefix and path must survive sanitization.""" | ||
| result = InputSanitizer.sanitize_message("#service, /GET/list") | ||
| assert ", " in result | ||
|
|
||
|
|
||
| class TestSanitizeMessageWhitespace: | ||
| """Documents whitespace normalisation rules that apply even to #service payloads. | ||
|
|
||
| Callers constructing #service payloads must use exactly one space after | ||
| the comma; this class documents what happens if they don't. | ||
| """ | ||
|
|
||
| def test_single_space_after_comma_preserved(self) -> None: | ||
| """A single space between the comma and the slash is NOT collapsed or removed.""" | ||
| msg = "#service, /POST/services/active/foo" | ||
| assert InputSanitizer.sanitize_message(msg) == msg | ||
|
|
||
| def test_double_space_after_comma_collapsed_to_single(self) -> None: | ||
| """Two consecutive spaces are collapsed to one; callers must send exactly one space.""" | ||
| result = InputSanitizer.sanitize_message("#service, /POST/services/active/foo") | ||
| assert result == "#service, /POST/services/active/foo" | ||
|
|
||
| def test_leading_whitespace_stripped(self) -> None: | ||
| result = InputSanitizer.sanitize_message( | ||
| " #service, /POST/services/active/foo" | ||
| ) | ||
| assert result == "#service, /POST/services/active/foo" | ||
|
|
||
| def test_trailing_whitespace_stripped(self) -> None: | ||
| result = InputSanitizer.sanitize_message( | ||
| "#service, /POST/services/active/foo " | ||
| ) | ||
| assert result == "#service, /POST/services/active/foo" | ||
|
|
||
| def test_tab_in_prefix_converted_to_space_then_collapsed(self) -> None: | ||
| """Tabs within the prefix are normalised along with spaces; a tab after the comma becomes a single space.""" | ||
| result = InputSanitizer.sanitize_message("#service,\t/POST/services/active/foo") | ||
| assert result == "#service, /POST/services/active/foo" | ||
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.
Uh oh!
There was an error while loading. Please reload this page.