Skip to content

Instantly share code, notes, and snippets.

View rocky's full-sized avatar

R. Bernstein rocky

View GitHub Profile
@rocky
rocky / test-bytecode.lap
Created October 9, 2017 21:37
Emacs Lisp bytecode disassembly for keyboard bindings
byte code:
args: nil
0 constant global-set-key
1 constant ""
2 constant backward-delete-char-untabify
3 call 2
4 discard
5 constant local-set-key
6 constant "m"
7 constant vm-mail
@rocky
rocky / maru-psa-extract.json
Last active November 6, 2018 20:17
Solc AST vs Maru
{
"type": "VariableDeclaration",
"typeName": {
"type": "ArrayTypeName",
"baseTypeName": {
"type": "ElementaryTypeName",
"name": "bytes32",
"loc": {
"start": {
"line": 4,
@rocky
rocky / FunctionDefinition.ts
Created November 23, 2018 13:08
Maru AntlR and solc AST for SWC-100
// Rules involving the solc FunctionDefinition AST node
"use strict";
import { Issue, Severity } from '../issue';
function defaultVisibilityFunctionViolation(node: any, issues: Issue[]): boolean {
if (node.attributes.visibility === "default") {
const mess = `Function ${node.attributes.name} visibility is not set and defaults to "public".`;
const issue = new Issue(node.src, "SWC-100", Severity.Warning, mess);
issues.push(issue);
@rocky
rocky / MemberAccess.ts
Created November 23, 2018 23:07
tx.origin antlr vs solc
// Return true if node is the tx.origin which refers to an
// address.
function txOriginViolation(node: any, issues: Issue[]): boolean {
const attrib = node.attributes;
if (attrib.type !== "address") {
return false;
}
if (attrib.member_name !== "origin") {
return false
}
@rocky
rocky / ConverLib2.json
Last active February 27, 2019 01:21
more MythX-friendly solc JSON
{
"contracts": {
"/home/rocky/truffle/mythjs-should-detect/bernhard_medium_post/contracts/ConvertLib.sol": {
"ConvertLib": {
"abi": [
{
"constant": true,
"inputs": [
{
"name": "amount",
@rocky
rocky / fileIndex.js
Created February 26, 2019 02:01
some truffle-security stuff.
#!/usr/bin/env node
const srcmap = require('../lib/srcmap');
const sourceMaps = [
// ConvertLib
["ConvertLib sourcemap",
"34:155:0:-;;132:2:-1;166:7;155:9;146:7;137:37;252:7;246:14;243:1;238:23;232:4;229:33;270:1;265:20;;;;222:63;;265:20;274:9;222:63;;298:9;295:1;288:20;328:4;319:7;311:22;352:7;343;336:24"],
["ConvertLib deployed",
"34:155:0:-;;;;;;;;;;;;;;;;;;;;;;;;;55:132;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;55:132:0;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;126:20;169:14;160:6;:23;153:30;;55:132;;;;:::o"],