Skip to content

Instantly share code, notes, and snippets.

@rocky
Created February 26, 2019 02:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rocky/f44d10da9740df4a85a52183fdbe5724 to your computer and use it in GitHub Desktop.
Save rocky/f44d10da9740df4a85a52183fdbe5724 to your computer and use it in GitHub Desktop.
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"],
// MetaCoin
["MetaCoin sourcemap",
"324:675:1:-;;;462:56;8:9:-1;5:2;;;30:1;27;20:12;5:2;462:56:1;509:5;487:8;:19;496:9;487:19;;;;;;;;;;;;;;;:27;;;;324:675;;;;;;"
],
["MetaCoin deployed",
"324:675:1:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;324:675:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;788:117;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;788:117:1;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;521:264;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;521:264:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;908:89;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;908:89:1;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;788:117;847:4;863:10;:18;882:16;893:4;882:10;:16::i;:::-;899:1;863:38;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;863:38:1;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;863:38:1;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;863:38:1;;;;;;;;;;;;;;;;856:45;;788:117;;;:::o;521:264::-;585:15;633:6;610:8;:20;619:10;610:20;;;;;;;;;;;;;;;;:29;606:47;;;648:5;641:12;;;;606:47;681:6;657:8;:20;666:10;657:20;;;;;;;;;;;;;;;;:30;;;;;;;;;;;713:6;691:8;:18;700:8;691:18;;;;;;;;;;;;;;;;:28;;;;;;;;;;;749:8;728:38;;737:10;728:38;;;759:6;728:38;;;;;;;;;;;;;;;;;;777:4;770:11;;521:264;;;;;:::o;908:89::-;962:4;979:8;:14;988:4;979:14;;;;;;;;;;;;;;;;972:21;;908:89;;;:::o"],
// Migrations
["Migrations sourceMap",
"34:483:2:-;;;189:50;8:9:-1;5:2;;;30:1;27;20:12;5:2;189:50:2;224:10;216:5;;:18;;;;;;;;;;;;;;;;;;34:483;;;;;;"
],
["Migrations deployed",
"34:483:2:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;34:483:2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;350:165;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;350:165:2;;;;;;;;;;;;;;;;;;;:::i;:::-;;82:39;;;:::i;:::-;;;;;;;;;;;;;;;;;;;58:20;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;243:103;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;243:103:2;;;;;;;;;;;;;;;;;:::i;:::-;;350:165;172:5;;;;;;;;;;;158:19;;:10;:19;;;154:26;;;412:19;445:11;412:45;;463:8;:21;;;485:24;;463:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;463:47:2;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;463:47:2;;;;179:1;154:26;350:165;:::o;82:39::-;;;;:::o;58:20::-;;;;;;;;;;;;;:::o;243:103::-;172:5;;;;;;;;;;;158:19;;:10;:19;;;154:26;;;332:9;305:24;:36;;;;154:26;243:103;:::o"]
];
let seenSoFar = new Set();
for (const [description, srcMap] of sourceMaps) {
/*
// Set difference from :
// http://2ality.com/2015/01/es6-set-operations.html
let difference = new Set(
[...a].filter(x => !b.has(x)));
*/
const s = srcmap.seenIndices(srcMap);
console.log(`${description}: ${[... s].sort()}`);
const difference = new Set(
[...s].filter(elt => !seenSoFar.has(elt)));
console.log(`${description} filtered: ${[... s].sort()}\n`);
seenSoFar = new Set([...seenSoFar, ...difference]);
}
console.log(`All indices seen: ${[... seenSoFar].sort()}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment