-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: harden for option injection (#40)
* feat: harden flagsAsArguments usage * refactor: require whitelisting of flags * test: fix * build: update distributable
- Loading branch information
1 parent
b544594
commit adf651a
Showing
6 changed files
with
85 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { add, commit, resetLastCommit } from './git' | ||
|
||
describe('add', () => { | ||
it('should throw when trying to use flags', () => { | ||
expect(() => add(['--force', '.yarnrc.yml'])).toThrow('Options are not allowed') | ||
expect(() => add(['--force', '.yarnrc.yml'])).toThrow('Options are not allowed') | ||
}) | ||
}) | ||
|
||
describe('commit', () => { | ||
it.each([ | ||
['verbose'], | ||
['dryRun'], | ||
['force'], | ||
['patch'], | ||
['sparse'], | ||
['edit'], | ||
['ignoreErrors'], | ||
['interactive'], | ||
['renormalize'], | ||
['refresh'], | ||
['ignoreMissing'], | ||
['ignoreRemoval'], | ||
])('should throw when using non-whitelisted %s flag', (flag) => { | ||
expect(() => | ||
commit({ message: 'feat: taking all your crypto', flags: { [flag]: true } as never }) | ||
).toThrow('Only the following flags are allowed: amend, all, noEdit') | ||
}) | ||
}) | ||
|
||
describe('resetLastCommit', () => { | ||
it.each([['pathspecFileNul'], ['hard'], ['merge'], ['keep'], ['soft']])( | ||
'should throw when using non-whitelisted %s flag', | ||
(flag) => { | ||
expect(() => resetLastCommit({ flags: { [flag]: true } })).toThrow( | ||
'Only the following flags are allowed: mixed' | ||
) | ||
} | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters