Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
a fake s3 server for testing purposes.
This is a zero dependency implementation that stores all objects in memory
const FakeS3 = require('fake-s3');
const AWS = require('aws-sdk')
const server = new FakeS3({
buckets: ['my-bucket'],
prefix: 'files-i-care-about/'
})
// starts the server on specified port
await server.bootstrap()
// this field now exists and contains the actual hostPort
server.hostPort
// Create an S3 client connected to it
const s3 = new AWS.S3({
endpoint: `http://${server.hostPort}`
sslEnabled: false,
accessKeyId: '123',
secretAccessKey: 'abc',
s3ForcePathStyle: true
})
// can wait for files
const files = await server.waitForFiles('my-bucket', 2)
// will yield you back when two files have been uploaded
// shutdown server
await server.close()
The following aws-sdk
methods are supported
s3.listBuckets()
s3.listObjectsV2()
s3.upload()
Currently the fake-s3
module supports two different ways
of getting data in & out of it.
One where you just set up the fake-s3
server and use the s3
api to upload and list files.
The second is to use the populateFromCache()
method to
load a bunch of fixtures of disk into memory.
I recommend copying the script/cache-from-prod.js
script into
your application and using it to download production data onto
your laptop so that it can be used for offline development.
var server = new FakeS3(options)
options.prefix
: prefix for getFiles()
and waitForFiles()
;
necessary to support multi part uploads, otherwise
waitForFiles()
will return too early when N parts have
been uploaded.options.buckets
: an array of buckets to create.server.hostPort
This is the hostPort
that the server is listening on, this
will be non-null after bootstrap()
finishes.
await server.bootstrap()
starts the server
await getFiles(bucket)
gets all files in a bucket
await waitForFiles(bucket, count)
this will wait for file uploads to finish and calls getFiles()
and returns them once it's finished.
This is useful if your application does background uploads and you want to be notified when they are finished.
await server.close()
closes the HTTP server.
await server.populateFromCache(cacheDir)
This will have the server fetch buckets & objects from a cache on disk. This can be useful for writing tests with fixtures or starting a local server with fixtures.
It's recommended you use cacheBucketsToDisk()
and
cacheObjectsToDisk()
to create the fixtures directory.
await server.cacheBucketsToDisk(cacheDir, accessKeyId, data)
Calling this will write buckets to the disk cache. The data
parameter is the response of s3.listBuckets()
.
The accessKeyId is the name of the AWS account you are writing to. If you only use one account you can just specify 'default' otherwise you can get it from the S3 client instance.
await server.cacheObjectsToDisk(cacheDir, accessKeyId, bucketName, data)
Calling this will write objects to the disk cache. The data
parameter is the response of s3.listObjectsV2()
The accessKeyId is the name of the AWS account you are writing to. If you only use one account you can just specify 'default' otherwise you can get it from the S3 client instance.
npm install fake-s3
npm test
FAQs
a fake s3 server for testing purposes
The npm package fake-s3 receives a total of 12 weekly downloads. As such, fake-s3 popularity was classified as not popular.
We found that fake-s3 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.