Skip to content

More pollution protection?#104

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: [] }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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