-
Notifications
You must be signed in to change notification settings - Fork 843
Protect Components: Use @wordpress/dataviews/wp import path #41510
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
nateweller
merged 6 commits into
add/protect/core-3
from
add/components/dataviews-wp-import
Mar 29, 2025
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9edd2dd
Use /wp import path with dataviews package
nateweller a8761cf
Add missing wordpress deps to dataviews build process for storybook
nateweller e4f9321
Remove initial ThreatsDataViews test
nateweller ae2cb0d
Revert "Remove initial ThreatsDataViews test"
nateweller 53d1977
Fix tests
nateweller dda7f23
Remove tests and stories from build
nateweller 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
Revert "Remove initial ThreatsDataViews test"
This reverts commit e4f9321.
- Loading branch information
commit ae2cb0d98b88b19e271ee3e4ac3c5ac856aab93d
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
projects/js-packages/scan/src/components/threats-data-views/test/index.test.jsx
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,82 @@ | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { ThreatsContextProvider } from '@automattic/jetpack-scan'; | ||
| import ThreatsDataViews from '../index.js'; | ||
|
|
||
| const data = [ | ||
| // Scan API Data | ||
| { | ||
| id: 185869885, | ||
| signature: 'EICAR_AV_Test', | ||
| title: 'Malicious code found in file: index.php', | ||
| description: | ||
| "This is the standard EICAR antivirus test code, and not a real infection. If your site contains this code when you don't expect it to, contact Jetpack support for some help.", | ||
| firstDetected: '2024-10-07T20:45:06.000Z', | ||
| fixedIn: null, | ||
| fixedOn: '2024-10-07T20:45:06.000Z', | ||
| fixable: { fixer: 'rollback', target: 'January 26, 2024, 6:49 am', extensionStatus: '' }, | ||
| fixer: { | ||
| status: 'in_progress', | ||
| startedAt: '2024-10-07T20:45:06.000Z', | ||
| lastUpdated: '2024-10-07T20:45:06.000Z', | ||
| }, | ||
| severity: 8, | ||
| status: 'current', | ||
| filename: '/var/www/html/wp-content/index.php', | ||
| context: { | ||
| 1: 'echo <<<HTML', | ||
| 2: 'X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*', | ||
| 3: 'HTML;', | ||
| marks: {}, | ||
| }, | ||
| }, | ||
| // Protect Report Data | ||
| { | ||
| id: '1d0470df-4671-47ac-8d87-a165e8f7d502', | ||
| title: 'WooCommerce <= 3.2.3 - Authenticated PHP Object Injection', | ||
| description: | ||
| 'Versions 3.2.3 and earlier are affected by an issue where cached queries within shortcodes could lead to object injection. This is related to the recent WordPress 4.8.3 security release.This issue can only be exploited by users who can edit content and add shortcodes, but we still recommend all users running WooCommerce 3.x upgrade to 3.2 to mitigate this issue.', | ||
| source: 'https://wpscan.com/vulnerability/1d0470df-4671-47ac-8d87-a165e8f7d502', | ||
| extension: { | ||
| name: 'WooCommerce', | ||
| slug: 'woocommerce', | ||
| version: '3.2.3', | ||
| type: 'plugins', | ||
| }, | ||
| fixedIn: '3.2.4', | ||
| }, | ||
| ]; | ||
|
|
||
| const mockProps = { | ||
| filters: [], | ||
| isSupportedEnvironment: true, | ||
| handleUpgradeClick: () => {}, | ||
| onFixThreats: () => {}, | ||
| onIgnoreThreats: () => {}, | ||
| onUnignoreThreats: () => {}, | ||
| isThreatEligibleForFix: () => true, | ||
| isThreatEligibleForIgnore: () => true, | ||
| isThreatEligibleForUnignore: () => true, | ||
| isUserConnected: true, | ||
| hasConnectedOwner: true, | ||
| userIsConnecting: false, | ||
| handleConnectUser: () => {}, | ||
| credentials: [], | ||
| credentialsIsFetching: false, | ||
| credentialsRedirectUrl: '/redirect-url', | ||
| onModalOpen: () => {}, | ||
| onModalClose: () => {}, | ||
| }; | ||
|
|
||
| describe( 'ThreatsDataViews', () => { | ||
| it( 'renders threat data', () => { | ||
| render( | ||
| <ThreatsContextProvider> | ||
| <ThreatsDataViews data={ data } { ...mockProps } /> | ||
| </ThreatsContextProvider> | ||
| ); | ||
| expect( screen.getByText( 'Malicious code found in file: index.php' ) ).toBeInTheDocument(); | ||
| expect( | ||
| screen.getByText( 'WooCommerce <= 3.2.3 - Authenticated PHP Object Injection' ) | ||
| ).toBeInTheDocument(); | ||
| } ); | ||
| } ); |
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 change to using the
@wordpress/dataviews/wpimport path appears to break tests that use the dataviews package... removed this basic render test for now.