Skip to content

More pollution protection? #104

@shadowspawn

Description

@shadowspawn

Prompted by @aaronccasanova in #74 (comment), I started thinking through related pollution scenarios (#74 (comment)).

If this is something we care about, we have room for improvement. 🙊

const { parseArgs } = require('@pkgjs/parseargs');

// Somebody trampled all over prototypes...
Object.prototype.strict = false;
Object.prototype.args = ['--pollution', 'happened'];
Object.prototype.pollution = { type: 'string'};

const knownOptions = {
    with: { short: 'w', type: 'string' },
    bool: { short: 'b', type: 'boolean' }
};

console.log(parseArgs({ options: knownOptions }));
% node pollution.js --with VALUE -b
{ values: { pollution: 'happened' }, positionals: [] }

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions