Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Solparse is a fork of Consensys' solidity-parser. Solium is heavily dependant on a parser for operating on the AST and so I needed full control over whichever parse was added as a depandancy to the linter. Hence, the fork which I maintain and have the flexibility to release whenever I need to.
A Solidity parser in Javascript. So we can evaluate and alter Solidity code without resorting to cruddy preprocessing.
This is pre-alpha software. The goal of it is to take Solidity code as input and return an object as output that can be used to correctly describe that Solidity code. The structure of the resultant object is highly likely to change as the parser's features get filled out. This parser is set to ignore Solidity constructs it's not yet able to handle. Or, it might just error. So watch out.
Library
npm install solidity-parser
Then, in your code:
const SolidityParser = require('solidity-parser');
// Parse Solidity code as a string:
const result = SolidityParser.parse('contract { ... }');
// Or, parse a file:
const result = SolidityParser.parseFile('./path/to/file.sol');
You can also parse a file specifically for its imports. This won't return an abstract syntax tree, but will instead return a list of files required by the parsed file:
const SolidityParser = require('solidity-parser');
const result = SolidityParser.parseFile('./path/to/file.sol', 'imports');
console.log(result);
// [
// 'SomeFile.sol',
// 'AnotherFile.sol'
// ]
Command Line (for convenience)
$ solidity-parser ./path/to/file.js
Consider this solidity code as input:
import "Foo.sol";
contract MyContract {
mapping (uint => address) public addresses;
}
You'll receiving the following (or something very similar) as output. Note that the structure of mappings could be made more clear, and this will likely be changed in the future.
{
"type": "Program",
"body": [
{
"type": "ImportStatement",
"value": "Foo.sol"
},
{
"type": "ContractStatement",
"name": "MyContract",
"is": [],
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "DeclarativeExpression",
"name": "addresses",
"literal": {
"type": "Type",
"literal": {
"type": "MappingExpression",
"from": {
"type": "Type",
"literal": "uint",
"members": [],
"array_parts": []
},
"to": {
"type": "Type",
"literal": "address",
"members": [],
"array_parts": []
}
},
"members": [],
"array_parts": []
},
"is_constant": false,
"is_public": true
}
}
]
}
]
}
In a checkout of the project, run:
$ npm test
MIT
FAQs
PEG.js Solidity parser for Javascript
The npm package solparse receives a total of 1,913 weekly downloads. As such, solparse popularity was classified as popular.
We found that solparse 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
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.