![Malicious npm Package Typosquats react-login-page to Deploy Keylogger](https://cdn.sanity.io/images/cgdhsj6q/production/007b21d9cf9e03ae0bb3f577d1bd59b9d715645a-1024x1024.webp?w=400&fit=max&auto=format)
Research
Security News
Malicious npm Package Typosquats react-login-page to Deploy Keylogger
Socket researchers unpack a typosquatting package with malicious code that logs keystrokes and exfiltrates sensitive data to a remote server.
hotfile
Advanced tools
Readme
Hotfile makes working with folders and files in node-js easy and clear.
$ npm i hotfile
const SOME_FOLDER_PATH = 'some-folder-path'
const aHotFolder = require('hotfile')(SOME_FOLDER_PATH)
const someAsyncFunction = async () => {
await aHotFolder.loadChildren()
console.log(aHotFolder)
}
someAsyncFunction()
##### console.log(aHotFolder)
{
"isFile": false,
"path": "home",
"basename": "home",
"size": 224,
"children": [
{
"isFile": false,
"path": "home/1",
"basename": "1",
"size": 192,
"children": []
},
...
{
"isFile": true,
"path": "home/an video file.mp4",
"basename": "an video file.mp4",
"size": 60,
"ext": ".mp4"
}
]
}
Below is a tree diagram of the folders and files that we will be using in this documentation. This diagram will hereinafter be referred to as "Diagram A"
/Users/YOUR_USER_NAME/Desktop/YOUR_PROJECT_NAME/home
├── 1
| ├── 2
| | └── 3
| | └── 4
| | └── 5
| | ├── a subtitle file.en.srt
| | ├── an audio file.mp3
| | └── a video file.mp4
| ├── a subtitle file.en copy.srt
| ├── an audio file.mp3
| └── a video file.mp4
├── a
| ├── a subtitle file.en.srt
| ├── an audio file.mp3
| ├── an video file.mp4
| └── b
| └── c
| └── d
| └── e
| ├── a subtitle file.en.srt
| ├── an audio file.mp3
| └── a video file.mp4
├── a subtitle file.en.srt
├── an audio file.mp3
└── a video file.mp4
directory: 10 file: 15
const SOME_FOLDER_PATH = 'home'
const SOME_FILE_PATH = 'home/a/a subtitle file.en.srt'
const aHotFolder = require('hotfile')(SOME_FOLDER_PATH)
const aHotFile = require('hotfile')(SOME_FILE_PATH)
If you would like to access the Hotfile and or HotfileError class
const SOME_FOLDER_PATH = 'home'
const SOME_FILE_PATH = 'home/a/a subtitle file.en.srt'
const { Hotfile, HotfileError } = require('hotfile')
const aHotFolder = Hotfile(SOME_FOLDER_PATH)
const aHotFile = Hotfile(SOME_FILE_PATH)
When you want to load the subfolders of a hotfile folder instance can specify certain parameters by passing an options object to the loadChildren function like so: instance.loadChildren(/* options */)
const options = {
id: true, // generates md5 hashes of an item's path and adds that to the item as its id property
depth: 3, // how deep down the directory tree it loads items, this is 0 by default.
files: true, // constructs an array of files present in the loaded folders and attaches it to the instance that called the load method.
cb: async (item) => { /* code in here runs for each loaded file and folder */ },
exclude: ['strings'], // files and folders matching any of the strings in this array will not be loaded
include: ['strings'], // files and folders matching any of the strings in this array will be loaded
$exclude: ['regex'], // files and folders matching any of the regular expressions in this array will not be loaded
$include: ['regex'] // files and folders matching any of the regular expressions in this array will be loaded
}
aHotFolder.loadChildren(options)
Note: filters can not be mixed, as such only one of the four filters (include, exclude, $include, $exclude) may be included in an object.
In this example we add md5 ids to each loaded item, load just 1 subfolder deep, collect the files in an array, filter out .SD_Store
files, and run an async call back function which renames and moves all files to another Hotfile folder instance.
const someAsyncFunction = async () => {
await aHotFolder.loadChildren({
id: true,
depth: 1,
files: true,
exclude: ['.DS_Store'],
cb: async (item) => {
const name = item.md5Id(new Date().toISOString())
const ext = 'mp4'
await item.setNameTo(name).setExtTo(ext).moveTo(anotherHotFolder)
}
})
}
someAsyncFunction()
In this example we load 5 levels deep and delete all files and folders.
const someAsyncFunction = async () => {
await aHotFolder.loadChildren({
depth: 5,
files: true,
cb: async (item) => {
await item.delete()
}
})
}
someAsyncFunction()
You can create subfolders in Hotfile folder instances by using the createFolder or createFolderSync method. Both of these return an instance of the newly created subfolder.
instance.createFolderSync(string) -> instance
instance.createFolder(string) -> instance
In the following example we create 4 nested folders A,B,C, and D.
const aHotFolderA = require('hotfile')(SOME_FOLDER_PATH)
const foldername = 'some-name-not-a-path'
const aHotfolderB = aHotFolderA.createFolderSync(foldername)
const aHotfolderC = aHotfolderB.createFolderSync(foldername)
const aHotfolderD = aHotfolderC.createFolderSync(foldername)
Hotfile file instances can be move from one Hotfile folder instance to another.
async instance.moveTo(instanec) -> instance
Hotfile file instances can be move from one Hotfile folder instance to another.
const aHotFolderA = require('hotfile')(SOME_FOLDER_PATH_A)
const aHotFolderB = require('hotfile')(SOME_FOLDER_PATH_A)
const aHotFile = require('hotfile')(SOME_FILE_PATH)
await aHotfile.moveTo(aHotFolderA)
await aHotfile.moveTo(aHotFolderB)
Hotfile file instances can be renamed.
instance.setNameTo(string) -> self
With Hotfiles renaming a file is made easy and clear with the setNameTo method. Note: the moveTo() method should be called for the rename to take place on the file system. Do not pass it any parameters when you call it.
const aHotFile = require('hotfile')(SOME_FILE_PATH)
const result = await aHotfile.setNameTo('a cool new name').moveTo()
Hotfile file instances their extensions can be changed.
instance.setExtTo(string) -> self
With Hotfiles changeing file extensions is made easy and clear with the setExtTo method. Note: the moveTo() method should be called for the rename to take place on the file system. Do not pass it any parameters when you call it.
const aHotFile = require('hotfile')(SOME_FILE_PATH)
const ext = '.mp4' // including the period is optional. It will work either way.
const result = await aHotfile.setExtTo('mp4').moveTo()
Hotfile file instances can be deleted from anywhere.
async instance.delete() -> boolean
Hotfile file instances can be move from one Hotfile folder instance to another.
const aHotFile = require('hotfile')(SOME_FILE_PATH)
const result = await aHotfile.delete()
FAQs
Unknown package
We found that hotfile 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 researchers unpack a typosquatting package with malicious code that logs keystrokes and exfiltrates sensitive data to a remote server.
Security News
The JavaScript community has launched the e18e initiative to improve ecosystem performance by cleaning up dependency trees, speeding up critical parts of the ecosystem, and documenting lighter alternatives to established tools.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.