Repository navigation
fix(frontend-ng): harden URL bindings in SigmaRule and LinkRedirectWarning #3982
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
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
65 changes: 65 additions & 0 deletions
65
timesketch/frontend-ng/src/components/Explore/LinkRedirectWarning.test.js
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,65 @@ | ||
| /* | ||
| Copyright 2026 Google Inc. All rights reserved. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| import { mount } from '@vue/test-utils'; | ||
| import Vuetify from 'vuetify'; | ||
| import Vue from 'vue'; | ||
| import { describe, it, expect, beforeEach } from 'vitest'; | ||
| import LinkRedirectWarning from './LinkRedirectWarning.vue'; | ||
|
|
||
| Vue.use(Vuetify); | ||
|
|
||
| describe('LinkRedirectWarning.vue', () => { | ||
| let vuetify; | ||
|
|
||
| beforeEach(() => { | ||
| vuetify = new Vuetify(); | ||
| }); | ||
|
|
||
| it('allows http/https contextUrl and does not double-escape ampersands', () => { | ||
| const wrapper = mount(LinkRedirectWarning, { | ||
| vuetify, | ||
| propsData: { | ||
| contextValue: 'a&b', | ||
| contextUrl: 'https://example.com/lookup?q=a&b=1', | ||
| }, | ||
| }); | ||
|
|
||
| expect(wrapper.vm.safeContextUrl).toBe('https://example.com/lookup?q=a&b=1'); | ||
| expect(wrapper.text()).toContain('https://example.com/lookup?q=a&b=1'); | ||
| expect(wrapper.text()).not.toContain('&'); | ||
|
|
||
| const continueBtn = wrapper.findAll('.v-btn').at(1); | ||
| expect(continueBtn.attributes('href')).toBe('https://example.com/lookup?q=a&b=1'); | ||
| expect(continueBtn.attributes('rel')).toBe('noopener noreferrer'); | ||
| expect(continueBtn.attributes('disabled')).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('blocks non-http(s) schemes in contextUrl and disables continue button', () => { | ||
| const wrapper = mount(LinkRedirectWarning, { | ||
| vuetify, | ||
| propsData: { | ||
| contextValue: 'payload', | ||
| contextUrl: 'javascript:alert(1)', | ||
| }, | ||
| }); | ||
|
|
||
| expect(wrapper.vm.safeContextUrl).toBeNull(); | ||
| const continueBtn = wrapper.findAll('.v-btn').at(1); | ||
| expect(continueBtn.attributes('href')).toBeUndefined(); | ||
| expect(continueBtn.attributes('disabled')).toBe('disabled'); | ||
| }); | ||
| }); |
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
69 changes: 69 additions & 0 deletions
69
timesketch/frontend-ng/src/components/LeftPanel/SigmaRule.test.js
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,69 @@ | ||
| /* | ||
| Copyright 2026 Google Inc. All rights reserved. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| import { mount, createLocalVue } from '@vue/test-utils'; | ||
| import Vuetify from 'vuetify'; | ||
| import Vuex from 'vuex'; | ||
| import Vue from 'vue'; | ||
| import { describe, it, expect, beforeEach } from 'vitest'; | ||
| import SigmaRule from './SigmaRule.vue'; | ||
|
|
||
| const localVue = createLocalVue(); | ||
| localVue.use(Vuex); | ||
| Vue.use(Vuetify); | ||
|
|
||
| describe('SigmaRule.vue', () => { | ||
| let vuetify; | ||
| let store; | ||
|
|
||
| beforeEach(() => { | ||
| vuetify = new Vuetify(); | ||
| store = new Vuex.Store({ | ||
| state: { | ||
| sketch: { id: 1 }, | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| it('renders references as plain text rather than clickable links', async () => { | ||
| const wrapper = mount(SigmaRule, { | ||
| localVue, | ||
| vuetify, | ||
| store, | ||
| propsData: { | ||
| sigmaRule: { | ||
| rule_uuid: '1234', | ||
| title: 'Suspicious Rule', | ||
| }, | ||
| }, | ||
| stubs: ['router-link'], | ||
| }); | ||
|
|
||
| await wrapper.setData({ | ||
| expanded: true, | ||
| detailedSigmaRule: { | ||
| references: [ | ||
| 'https://example.com/advisory', | ||
| 'javascript:alert(document.domain)', | ||
| ], | ||
| }, | ||
| }); | ||
|
|
||
| expect(wrapper.findAll('a').length).toBe(0); | ||
| expect(wrapper.text()).toContain('https://example.com/advisory'); | ||
| expect(wrapper.text()).toContain('javascript:alert(document.domain)'); | ||
| }); | ||
| }); | ||
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.
Uh oh!
There was an error while loading. Please reload this page.