Skip to content

Instantly share code, notes, and snippets.

View rocky's full-sized avatar

R. Bernstein rocky

View GitHub Profile
@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"],
@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 / 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 / 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 / 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 / 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 / gcd-phase1.lap
Last active October 4, 2017 21:30
Amazing emacs decompilation
# preprocessed disassembly. Fake "LABEL" and "COME_FROM" instructions have been added
0 VARREF a
1 VARREF b
2 GTR
3 GOTO-IF-NIL 1
6 VARREF a
7 VARBIND c
8 VARREF b
9 VARSET a
10 VARREF c
@rocky
rocky / test-um.py
Last active July 20, 2016 14:32
um
import unittest
from um import Um
class TestUmspec(unittest.TestCase):
def test_bits(self):
x = int('1101', 2)
for start, l, expect in (
(28, 1, 1),
@rocky
rocky / style.zsh
Last active June 3, 2022 02:54
possible zshdb set style code
# -*- shell-script -*-
# "set highlight" debugger command
#
# Copyright (C) 2015 Rocky Bernstein <rocky@gnu.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2, or
# (at your option) any later version.
#
@rocky
rocky / Emacs25-build.png
Last active October 17, 2015 09:53
Emacs 25 build profile
Emacs25-build.png