Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@thisismanta/pessimist
Advanced tools
```ts import { parseArguments } from '@thisismanta/pessimist'
import { parseArguments } from '@thisismanta/pessimist'
const { count, dryRun, outputFileName, ...positionalArguments } =
parseArguments(
process.argv.slice(2),
{
count: 0,
dryRun: false,
outputFileName: '',
exclude: [],
}
)
for (const item of Array.from(positionalArguments)) {
// ...
}
file1 file2 --count=3 --output-file-name=file3
{
// From the positional arguments
'0': 'file1',
'1': 'file2',
length: 2,
// From the named arguments
outputFileName: 'file3',
dryRun: true,
// From the defaults
count: 0,
exclude: [],
}
The below commands exit with non-zero code as somethingElse
is not defined in the default object (the second parameter of parseArguments
function).
--something-else
# Error: Unexpected an unknown argument: --something-else
Therefore it is important to have all the possible field-value arguments defined in the default object.
The below commands yield the same output because dry-run
is transformed into a camel case.
--dryRun # { dryRun: true }
--dry-run # { dryRun: true }
The below commands yield the same output.
--dryRun=false # { dryRun: false }
--dryRun=False
--dryRun=FALSE
--dryRun=n
--dryRun=no
--dryRun=0
Having no
argument prefix negates the Boolean value.
--noDryRun # { dryRun: false }
--no-dry-run # { dryRun: false }
--no-dry-run=false # { dryRun: true }
Having no
argument prefix clears the string value.
--noOutputFileName # { outputFileName: '' }
--no-output-file-name # { outputFileName: '' }
Having no
argument prefix for an array removes the given value from the output array.
--exclude=file1 --exclude=file2 --no-exclude=file1
# { exclude: ['file2'] }
--exclude=file1 --exclude=file2 --exclude=file1
# { input: ['file2', 'file1'] }
parseArguments(
process.argv.slice(2),
{ dryRun: false },
{ aliases: { d: 'dryRun', commit: '!dryRun' } }
)
node myfile --dryRun # { dryRun: true }
node myfile -d # { dryRun: true }
However, the below commands yield the opposite outputs because !
prefix negates the value from commit
.
node myfile --commit # { dryRun: false }
node myfile --noCommit # { dryRun: true }
node myfile --no-commit # { dryRun: true }
parseArguments(
process.argv.slice(2),
{
dryRun: false,
confirmed: true,
},
{
exclusives: [['dryRun', 'confirmed'], ...],
}
)
--dryRun --confirmed
# Error: Unexpected mutual exclusive arguments: --dryRun --confirmed
FAQs
```ts import { parseArguments } from '@thisismanta/pessimist'
We found that @thisismanta/pessimist demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.