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.
fetch-mocker
Advanced tools
mocker for fetch requests in browser
npm install fetch-mocker
import Mocker from "fetch-mocker"
const mocker = new Mocker()
mocker.requestDelay = 1000
let persons = [
{ id : "1", civility : "mister", firstName : "Jean", lastName : "Dupont" },
{ id : "2", civility : "madame", firstName : "Catherine", lastName : "Durand" },
{ id : "3", civility : "mister", firstName : "Jean-Pierre", lastName : "Martin" }]
mocker.get("/api/persons", () => persons)
const findPerson = id => persons.find(item => item.id === id)
mocker.get("/api/persons/:id", request => {
const id = request.params.id
const person = findPerson(id)
return person ? person : mocker.makeResponse("Unknown person", 404)
})
mocker.delete("/bcu/persons/:id", request => {
const id = request.params.id
persons = persons.filter(person => person.id !== id)
})
mocker.put("/api/persons/:id", request => {
const id = request.params.id
const fields = JSON.parse(request.body)
const person = findPerson(id)
if (!person) return mocker.makeResponse("Unknown person", 404)
for (const n in fields) {
if (person.hasOwnProperty(n)) person[n] = fields[n]
}
return person
})
mocker.post("/api/persons/", request => {
const newPerson = JSON.parse(request.body)
const id = Number(persons[persons.length - 1].id) + 1
newPerson.id = String(id)
persons.push(newPerson)
return { id }
})
mocker.enable()
FAQs
mocker for fetch requests in browser
We found that fetch-mocker 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.