-
Notifications
You must be signed in to change notification settings - Fork 171
fix: harden frontend security entrypoints #7601
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
Open
fairlighteth
wants to merge
13
commits into
develop
Choose a base branch
from
fix/deepsec-high-frontend-hardening
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c1632c1
fix: harden frontend security entrypoints
fairlighteth 52ab0e6
fix: avoid impossible Pinata secret warning check
fairlighteth 92b6fa6
Merge remote-tracking branch 'origin/develop' into fix/deepsec-high-f…
fairlighteth 07eeda1
chore(i18n): extract i18n strings [automatic]
github-actions[bot] bab9370
fix: allow IPv6 localhost in safe link validation
fairlighteth 7f257f6
fix: keep explorer URLs slash-stable
fairlighteth 247e3d5
fix: sanitize hook simulation links
fairlighteth baa687e
chore(i18n): extract i18n strings [automatic]
github-actions[bot] b8cfaa6
Merge branch 'develop' into fix/deepsec-high-frontend-hardening
fairlighteth f5bd41c
fix: resolve lint blockers in PR 7601
fairlighteth 1730230
Merge branch 'develop' into fix/deepsec-high-frontend-hardening
Danziger 20ea495
Merge origin/develop into fix/deepsec-high-frontend-hardening
fairlighteth 88f524e
Merge branch 'develop' into fix/deepsec-high-frontend-hardening
fairlighteth 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
77 changes: 77 additions & 0 deletions
77
apps/cowswap-frontend/src/common/containers/OrderHooksDetails/HookItem/index.test.tsx
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,77 @@ | ||
| import React from 'react' | ||
|
|
||
| import { HookDappType, HookToDappMatch, CowHookDetails } from '@cowprotocol/hook-dapp-lib' | ||
|
|
||
| import { i18n } from '@lingui/core' | ||
| import { I18nProvider } from '@lingui/react' | ||
| import { fireEvent, render, screen } from '@testing-library/react' | ||
| import { ThemeProvider as StyledComponentsThemeProvider } from 'styled-components/macro' | ||
| import { getCowswapTheme } from 'theme' | ||
|
|
||
| import { useSimulationData } from 'modules/tenderly/hooks/useSimulationData' | ||
|
|
||
| import { HookItem } from './index' | ||
|
|
||
| jest.mock('modules/tenderly/hooks/useSimulationData', () => ({ | ||
| useSimulationData: jest.fn(), | ||
| })) | ||
|
|
||
| const mockUseSimulationData = useSimulationData as jest.MockedFunction<typeof useSimulationData> | ||
|
|
||
| i18n.load('en-US', {}) | ||
| i18n.activate('en-US') | ||
|
|
||
| const details: CowHookDetails = { | ||
| uuid: 'hook-1', | ||
| hook: { | ||
| target: '0x1111111111111111111111111111111111111111', | ||
| callData: '0xdeadbeef', | ||
| gasLimit: '100000', | ||
| dappId: 'test-hook', | ||
| }, | ||
| } | ||
|
|
||
| const item: HookToDappMatch = { | ||
| dapp: { | ||
| id: 'test-hook', | ||
| name: 'Test hook', | ||
| descriptionShort: 'Test description', | ||
| type: HookDappType.IFRAME, | ||
| version: '1.0.0', | ||
| website: 'https://cow.fi', | ||
| image: 'https://cow.fi/icon.png', | ||
| }, | ||
| hook: details.hook, | ||
| } | ||
|
|
||
| function renderComponent(): ReturnType<typeof render> { | ||
| return render( | ||
| <I18nProvider i18n={i18n}> | ||
| <StyledComponentsThemeProvider theme={getCowswapTheme(false)}> | ||
| <HookItem details={details} item={item} index={0} /> | ||
| </StyledComponentsThemeProvider> | ||
| </I18nProvider>, | ||
| ) | ||
| } | ||
|
|
||
| describe('HookItem', () => { | ||
| beforeEach(() => { | ||
| mockUseSimulationData.mockReturnValue({ | ||
| id: 'simulation-1', | ||
| link: 'javascript:alert(1)', | ||
| status: false, | ||
| cumulativeBalancesDiff: {}, | ||
| stateDiff: [], | ||
| gasUsed: '0', | ||
| }) | ||
| }) | ||
|
|
||
| it('renders an invalid simulation link as inert text', () => { | ||
| renderComponent() | ||
|
|
||
| fireEvent.click(screen.getByText('Test hook')) | ||
|
|
||
| expect(screen.queryByRole('link', { name: 'Simulation failed' })).toBeNull() | ||
| expect(screen.getByText('Simulation failed')).not.toBeNull() | ||
| }) | ||
| }) |
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
8 changes: 4 additions & 4 deletions
8
apps/cowswap-frontend/src/legacy/state/application/localWarning.ts
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 |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| import { PINATA_API_KEY, PINATA_SECRET_API_KEY } from '@cowprotocol/common-const' | ||
| import { PINATA_API_KEY } from '@cowprotocol/common-const' | ||
| import { isLocal } from '@cowprotocol/common-utils' | ||
|
|
||
| let warningMsg | ||
|
|
||
| if ((!PINATA_SECRET_API_KEY || !PINATA_API_KEY) && isLocal) { | ||
| if (!PINATA_API_KEY && isLocal) { | ||
| warningMsg = | ||
| "Pinata env vars not set. Order appData upload won't work! " + | ||
| 'Set REACT_APP_PINATA_API_KEY and REACT_APP_PINATA_SECRET_API_KEY' | ||
| "Pinata public env var not set. Order appData upload won't work! " + | ||
| 'Set REACT_APP_PINATA_API_KEY and configure the required server-side Pinata credentials separately.' | ||
| } | ||
|
|
||
| export const localWarning = warningMsg | ||
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.
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.
🧩 Analysis chain
🏁 Script executed:
Repository: cowprotocol/cowswap
Length of output: 7535
Avoid implicit
anyforwarningMsg(apps/cowswap-frontend/src/legacy/state/application/localWarning.ts:4)let warningMsghas no initializer or type annotation, so withnoImplicitAny: trueit becomes implicitlyany. Type it asstring | undefined.Proposed fix
🤖 Prompt for AI Agents
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.
Not applying this one.
let warningMsghere is not a demonstratednoImplicitAnyfailure in TypeScript; this pattern is accepted as an evolving type in this control flow. Adding: string | undefinedwould be harmless cleanup, but I am keeping this PR scoped to the actual lint blockers.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.
@fairlighteth, understood — TypeScript's control flow analysis infers the evolvingstring | undefinedtype correctly here without an explicit annotation, so the existing pattern is fine. Happy to leave it as-is.🐇 (mild acceptance)
✏️ Learnings added
🧠 Learnings used