Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Node.js files manager module for easy management of files repository in projects.
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js. Tested on 10.x Node.js node version.
Installation is done using npm install
command:
$ npm install files-repo
const FilesManager = require("files-repo");
let f = FilesManager( { Path: PATH_TO_FILES_REPOSITORY, Size: REPOSITORY_SIZE } );
Where:
Adds an existing file located at 'pathToFile'. If fileId is provided, then will be used as file ID for that existing file.
Returns the file ID for the new file added.
Sample from tests:
let f = Files( { Path: PATH_TO_FILES_REPOSITORY, Size: REPOSITORY_SIZE } );
let fileId = await f.AddExistingFile( Path.join( PATH_TO_SAMPLE_FILES, "testfile01.txt" ) );
Assert.equal( fileId.length, 32 );
Adds a new file from a buffer.
Returns the file ID for the new file added.
Sample from tests:
let f = Files( { Path: PATH_TO_FILES_REPOSITORY, Size: REPOSITORY_SIZE } );
let fileBuffer = Buffer.from("This is a test buffer");
let fileId = await f.AddFromBuffer( fileBuffer );
Assert.equal( fileId.length, 32 );
Reads a file given its file ID.
Sample from tests:
let f = Files( { Path: PATH_TO_FILES_REPOSITORY, Size: REPOSITORY_SIZE } );
let fileBuffer = Buffer.from("This is a test buffer");
let fileId = await f.AddFromBuffer( fileBuffer );
let fileRead = await f.ReadFile( fileId );
Assert.isTrue( fileBuffer.equals(fileRead) );
Checks if a file exists given its file ID
Sample from tests:
let f = Files( { Path: PATH_TO_FILES_REPOSITORY, Size: REPOSITORY_SIZE } );
let fileBuffer = Buffer.from("This is a test buffer");
let fileId = await f.AddFromBuffer( fileBuffer );
let exists = await f.ExistsFile( fileId );
Assert.isTrue( exists );
Removes file given its file ID
Sample from tests:
let f = Files( { Path: PATH_TO_FILES_REPOSITORY, Size: REPOSITORY_SIZE } );
let fileBuffer = Buffer.from("This is a test buffer");
let fileId = await f.AddFromBuffer( fileBuffer );
await f.DeleteFile( fileId );
Gets the JSON file manifest.
This JSON object has this self description properties using one real sample:
{
"fileId": "3598af972306401b925ef163dfa649b3",
"length": 21,
"extension": "bin",
"created": "2019-10-14T07:50:22.945Z",
"location": "/home/rgb/dev/projects/files/test/testfilesrepository/dfa649b3/3598af972306401b925ef163dfa649b3.bin" }
Sample from tests:
let f = Files( { Path: PATH_TO_FILES_REPOSITORY, Size: REPOSITORY_SIZE } );
let fileBuffer = Buffer.from("This is a test buffer");
let fileId = await f.AddFromBuffer( fileBuffer );
let fileManifest = await f.GetFileManifest( fileId );
Iterates by all files in the repository and performs one call by file to fnc function with their filemanifests.
Sample from tests:
let f = Files( { Path: PATH_TO_FILES_REPOSITORY, Size: REPOSITORY_SIZE } );
let filesRead = 0;
let callback = async function( fileManifest ) { filesRead++; }
await f.IterateAll( callback );
Assert.isTrue( filesRead > 0 );
FAQs
Files manager module for easy files managemente in a NodeJS project
We found that files-repo 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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.