Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
pegjs-strip
Advanced tools
pegjs-strip is a utility for removing Javascript code fragments from the specified PEG.js grammer file.
The utility removes all code-related statements such as the initializer block, actions and labels. The semantic predicate &{<code>}
and !{<code>}
are replaced with &{return true;}
or !{return false;}
respectively.
By default, the utility does not strip comment blocks. To remove comments, --strip-comment
option can be used.
Usage: pegjs-strip [options] file
Options:
-h, --help show this help.
--strip-comment Strip comments.
--keep-initializer Keep the initializer block.
--keep-action Keep actions.
--keep-label Keep labels.
--keep-semantic-predicate Keep semantic predicates.
The following grammer is from the PEG.js documentation.
start
= additive
additive
= left:multiplicative "+" right:additive { return left + right; }
/ multiplicative
multiplicative
= left:primary "*" right:multiplicative { return left * right; }
/ primary
primary
= integer
/ "(" additive:additive ")" { return additive; }
integer "integer"
= digits:[0-9]+ { return parseInt(digits.join(""), 10); }
To remove all the code in the grammer, just run the utility with the grammer file as the first argument. The result is then written to the standard output as follows.
$ pegjs-strip example.pegjs
start
= additive
additive
= multiplicative "+" additive
/ multiplicative
multiplicative
= primary "*" multiplicative
/ primary
primary
= integer
/ "(" additive ")"
integer "integer"
= [0-9]+
--keep-label
option is available to leave all labels in the resulting output.
$ pegjs-strip --keep-label example.pegjs
start
= additive
additive
= left:multiplicative "+" right:additive
/ multiplicative
multiplicative
= left:primary "*" right:multiplicative
/ primary
primary
= integer
/ "(" additive:additive ")"
integer "integer"
= digits:[0-9]+
FAQs
A utility for removing Javascript code from the PEG.js grammer file.
The npm package pegjs-strip receives a total of 0 weekly downloads. As such, pegjs-strip popularity was classified as not popular.
We found that pegjs-strip 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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.