Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@miranext/request
Advanced tools
React Testify are set of context providers to make it easier to inject replacement of common global objects.
React Testify are set of context providers to make it easier to inject replacement of common global objects.
Warning: early stage and experimental af
Use it to swap out objects within the global window object.
import { WindowContextProvider } from 'react-testify';
export function Index() {
return (
<WindowContextProvider>
<App />
</WindowContextProvider>
)
}
We can now then use the windowContext from within the children.
import { useWindow } from 'react-testify'
...
export function ItemsView() {
const [items, setItems] = React.useState<Item>([])
const window = useWindow()
const callback = React.callback(async () => {
const res = await window.fetch('/api/items')
const data = await res.json()
setItems(data)
}, [])
return (
<ul>
{ items.map(item => {
return <li key={item.id}>{item.name}</li>
})}
</ul>
)
}
Now to test we can use the TestWindowContextProvider to provide any partial implementation
// file: EventListener.test.ts
import { render, screen } from '@testing-ibrary/react'
import { EventListener } from '../component/EventListner'
import fetchMock from 'fetch-mock'
describe('EventListener', () => {
it('renders events as it comes', () => {
const fetch = fetchMock.sandbox()
const updateMock = fetch.mock('/api/company/update',{
code: 0, data: {
_id: 'b1',
name: 'My New CompanyName'
}
})
render(
<TestWindowContextProvider fetch={fetch}>
<MyComponent />
</TestWindowContextProvider>
)
await screen.findByText('Name updated to My New CompanyName')
})
})
To test mock nextjs router
import { RouterContextTestProvider } from 'react-testify/next/RouterContextTestProvider';
<RouterContextTestProvider router={{ basePath: '/some/path' }}>
<MyComponent >
</RouterContextTestProvider>
FAQs
React Testify are set of context providers to make it easier to inject replacement of common global objects.
We found that @miranext/request demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.