-
Notifications
You must be signed in to change notification settings - Fork 30
Security hardening: token validation and service URL improvements #515
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
13 commits
Select commit
Hold shift + click to select a range
a306f91
Fix for isCallToolResult always returning false
corinagum d5575ae
Fix scope validation so User.Read no longer incorrectly matches User.…
corinagum 8e5ac5a
Dev environment guard where production will DevTools production env w…
corinagum 45f08ed
Adds a domain allowList that rejects serviceUrls not from known domains
corinagum 82239ae
Lint
corinagum 8378bbb
Narrow scope for trafficmanager.net
corinagum afaf4b2
Remove skipServiceUrlValidation
corinagum 32cfbb1
Source service URL allowlist from cloud environment presets
corinagum a17a2e3
Add GCC service url
corinagum 246b194
Avoid repeating rejected service urls
corinagum 6be89cd
Check originalNodeEnv for undefined
corinagum a9236c8
Address PR feedback: exact hostname matching, https enforcement, logg…
corinagum 1495736
Remove unnecessary log
corinagum 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import { McpPlugin } from './plugin'; | ||
|
|
||
| // Test subclass to access protected method | ||
| class TestMcpPlugin extends McpPlugin { | ||
| public testIsCallToolResult(value: any): boolean { | ||
| return this.isCallToolResult(value); | ||
| } | ||
| } | ||
|
|
||
| describe('McpPlugin', () => { | ||
| describe('isCallToolResult', () => { | ||
| let plugin: TestMcpPlugin; | ||
|
|
||
| beforeEach(() => { | ||
| plugin = new TestMcpPlugin(); | ||
| }); | ||
|
|
||
| it('should return true for valid CallToolResult with text content', () => { | ||
| const result = { | ||
| content: [{ type: 'text', text: 'hello' }], | ||
| }; | ||
| expect(plugin.testIsCallToolResult(result)).toBe(true); | ||
| }); | ||
|
|
||
| it('should return true for valid CallToolResult with image content', () => { | ||
| const result = { | ||
| content: [{ type: 'image', data: 'base64...', mimeType: 'image/png' }], | ||
| }; | ||
| expect(plugin.testIsCallToolResult(result)).toBe(true); | ||
| }); | ||
|
|
||
| it('should return true for valid CallToolResult with resource content', () => { | ||
| const result = { | ||
| content: [{ type: 'resource', resource: {} }], | ||
| }; | ||
| expect(plugin.testIsCallToolResult(result)).toBe(true); | ||
| }); | ||
|
|
||
| it('should return true for mixed content types', () => { | ||
| const result = { | ||
| content: [ | ||
| { type: 'text', text: 'hello' }, | ||
| { type: 'image', data: 'base64...' }, | ||
| ], | ||
| }; | ||
| expect(plugin.testIsCallToolResult(result)).toBe(true); | ||
| }); | ||
|
|
||
| it('should return false for null', () => { | ||
| expect(plugin.testIsCallToolResult(null)).toBe(false); | ||
| }); | ||
|
|
||
| it('should return false for undefined', () => { | ||
| expect(plugin.testIsCallToolResult(undefined)).toBe(false); | ||
| }); | ||
|
|
||
| it('should return false for object without content', () => { | ||
| expect(plugin.testIsCallToolResult({ text: 'hello' })).toBe(false); | ||
| }); | ||
|
|
||
| it('should return false for plain string', () => { | ||
| expect(plugin.testIsCallToolResult('hello')).toBe(false); | ||
| }); | ||
|
|
||
| it('should return false for content with unknown type', () => { | ||
| const result = { | ||
| content: [{ type: 'unknown', data: 'foo' }], | ||
| }; | ||
| expect(plugin.testIsCallToolResult(result)).toBe(false); | ||
| }); | ||
|
|
||
| it('should return false for non-array content', () => { | ||
| const result = { | ||
| content: 'not an array', | ||
| }; | ||
| expect(plugin.testIsCallToolResult(result)).toBe(false); | ||
| }); | ||
| }); | ||
| }); |
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
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
Oops, something went wrong.
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.