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.
Big Friendly Gateway creates a read and write stream to various cloud storage providers
Big Friendly Gateway creates a read and write stream to various cloud storage providers
BFG is also the Big Friendly Giant
$ npm install bfg
bfg will create a WriteStream for uploads and a ReadStream for downloads to cloud storage providers.
Upload a local file to rackspace:
var fs = require('fs');
var bfg = require('bfg');
var disk = bfg.rackspace({
username:'...',
apikey:'...',
region:'LON',
container:'my'
})
var localfile = fs.createReadStream(__dirname + '/hello.txt');
var remotefile = disk.createWriteStream('/hello.txt');
localfile.on('end', function(){
console.log('file uploaded!');
})
localfile.pipe(remotefile);
Because bfg is streaming - you can use pipe readstreams to HTTP responses:
var disk = bfg.rackspace(...);
// proxy any request to /filestore to rackspace to serve
app.use('/filestore', function(req, res){
disk.createReadStream(req.url).pipe(res);
})
bfg will also stream form uploads that contain files - this is useful for file uploads that you want to stream directly to the cloud provider:
var app = express();
var disk = bfg.rackspace(...);
app.use('/filestore', disk.handler());
bfg can be used on the cli if you install it globally:
$ npm install bfg -g
you can then pipe files to and from bfg - the options are configured on the command line:
Usage: bfg [options] [command]
Commands:
upload upload a file
download download a file
Options:
-h, --help output usage information
-u, --username [value] Rackspace Username
-k, --apikey [value] Rackspace Api Key
-r, --region [value] Rackspace Region
-c, --container [value] Rackspace Container
-f, --folder [value] Rackspace Folder
-V, --version output the version number
These options can also be configured from the envionment variables:
Assuming the environment variables are set - here is an example of streaming a local file to rackspace:
$ cat helloworld.txt | bfg upload /helloworld.txt
And streaming from rackspace to a local file:
$ bfg download /helloworld.txt > helloworld.txt
Create a new disk from one of the cloud providers bfg supports. The options vary depending on provider:
Create a ReadStream from the contents of the remote filepath
var disk = bfg.rackspace(...);
disk.createReadStream('/hello.txt').pipe(fs.createWriteStream(__dirname + '/hello.txt'));
Create a WriteStream for the remote filepath
var disk = bfg.rackspace(...);
fs.createReadStream(__dirname + '/hello.txt').pipe(disk.createWriteStream('/hello.txt'));
Create a HTTP handler that will GET or POST requests via the appropriate stream
var app = express();
var disk = bfg.rackspace(...);
app.use('/filestore', disk.handler());
You can instruct bfg to redirect GET requests to the CDN for the container.
First you must pass the cdn option when you make a disk.
Second pass true to the handler function to get a handler that will redirect rather than stream directly:
var disk = bfg.rackspace({
username:...,
etc:...,
cdn:'https://bf9164d97a0cd15823f4-4dba8edb0fc2b3e5cc0f769b1eea32ba.ssl.cf3.rackcdn.com'
})
app.use('/filestore', disk.handler(true));
Return a new disk that will save and load files relative to the given basepath
This is useful for partitioning a container for serveral projects.
var app = express();
var disk = bfg.rackspace(...);
var folder = disk.folder('/subfolder')
fs.createReadStream(__dirname + '/hello.txt').pipe(disk.createWriteStream('/hello.txt'));
The file is saved to '/subfolder/hello.txt'
triggered when a file is uploaded to a disk
triggered when a file is downloaded from a disk
MIT
FAQs
Big Friendly Gateway creates a read and write stream to various cloud storage providers
The npm package bfg receives a total of 23 weekly downloads. As such, bfg popularity was classified as not popular.
We found that bfg 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.