From ecfa23c31865db1fdc73160614d3f43da99b4aa1 Mon Sep 17 00:00:00 2001 From: rarecoil Date: Fri, 12 Jul 2019 12:52:30 -0700 Subject: [PATCH] add declarations --- dist/Sinkdweller.d.ts | 89 ++++++++++++++++++++++++++++++++++++ dist/Sinkdweller.js | 2 +- dist/Sinkdweller.js.map | 2 +- dist/Sinkdweller.test.d.ts | 1 + dist/Sinkdweller.test.js | 77 +++++++++++++++++++++++++++++++ dist/Sinkdweller.test.js.map | 1 + package.json | 2 +- tsconfig.json | 5 +- 8 files changed, 174 insertions(+), 5 deletions(-) create mode 100644 dist/Sinkdweller.d.ts create mode 100644 dist/Sinkdweller.test.d.ts create mode 100644 dist/Sinkdweller.test.js create mode 100644 dist/Sinkdweller.test.js.map diff --git a/dist/Sinkdweller.d.ts b/dist/Sinkdweller.d.ts new file mode 100644 index 0000000..e58f012 --- /dev/null +++ b/dist/Sinkdweller.d.ts @@ -0,0 +1,89 @@ +declare type SeedFunction = () => number; +interface RadamsaOptions { + [key: string]: any; + output_file?: string; + meta_output_file?: string; + count?: number; + seed?: number | SeedFunction; + mutations?: Array; + patterns?: Array; + generators?: Array; + recursive?: boolean; + seek?: number; + truncate?: boolean; + delay?: number; + checksums?: number; + hash?: string; + use_external_radamsa?: boolean; +} +declare class Sinkdweller { + private DEFAULT_OPTIONS; + private options; + /** + * Create a new Sinkdweller shim around the Radamsa fuzzer. + * + * @param opts Options to pass radamsa executable. + */ + constructor(opts?: RadamsaOptions); + /** + * Fuzz input asynchronously. + * + * @param input String or buffer to feed Radamsa. + * @param callback callback to fire upon Radamsa completion. + */ + fuzz(input: string | Buffer, callback: any): void; + /** + * Fuzz input asynchronously with a promisified async function. + * + * @param input String or buffer to feed Radamsa. + * @returns a promise containing an error or the fuzzed string|Buffer. + */ + fuzzAsync(input: string | Buffer): Promise; + /** + * Fuzz input synchronously, waiting for Radamsa. + * + * @param input String or buffer to feed Radamsa. + * @returns fuzzed input in the type originally input. + */ + fuzzSync(input: string | Buffer): string | Buffer; + /** + * Sets flags for radamsa options. + * + * @param opts Options object. + */ + setFlags(opts: RadamsaOptions): void; + /** + * Set a seed function or number. + * + * @param seed_or_generator number or seed function + */ + setSeed(seed_or_generator: number | SeedFunction): void; + /** + * Asychronously spawn Radamsa. + * + * @param input String or buffer to push to Radamsa STDIN. + * @param callback Callback to send data to. + * @param options Radamsa option flags. + */ + protected spawnRadamsa(input: string | Buffer, callback: any, options?: RadamsaOptions): void; + /** + * Synchronously spawn radamsa. + * + * @param input Input string or buffer to radamsa STDIN + * @param options Raw radamsa options. + */ + protected spawnRadamsaSync(input: string | Buffer, options?: RadamsaOptions): Buffer; + /** + * Get the correct platform-specific radamsa executable to use. + * + * @param use_external Use a radamsa on $PATH. + */ + protected getRadamsaExecutable(use_external?: boolean): string; + /** + * Generate Radamsa command line arguments from the options array. + * + * @param options Radamsa options array. + */ + protected generateRadamsaFlags(options: RadamsaOptions): Array; +} +export = Sinkdweller; diff --git a/dist/Sinkdweller.js b/dist/Sinkdweller.js index 3ad123b..469a015 100644 --- a/dist/Sinkdweller.js +++ b/dist/Sinkdweller.js @@ -75,7 +75,7 @@ class Sinkdweller { fuzzAsync(input) { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => { - this.spawnRadamsa(input, (err, result) => { + this.fuzz(input, (err, result) => { if (err) { reject(err); } diff --git a/dist/Sinkdweller.js.map b/dist/Sinkdweller.js.map index 765548b..e869591 100644 --- a/dist/Sinkdweller.js.map +++ b/dist/Sinkdweller.js.map @@ -1 +1 @@ -{"version":3,"file":"Sinkdweller.js","sourceRoot":"","sources":["../src/Sinkdweller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA+C;AAC/C,2CAA6B;AAC7B,uCAAyB;AAqBzB,MAAM,gBAAiB,SAAQ,KAAK;CAAG;AAAA,CAAC;AAExC,MAAM,WAAW;IAuBb;;;;OAIG;IACH,YAAa,IAAoB;QA1BjC,mBAAmB;QACX,oBAAe,GAAkB;YACrC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I,EAAE;gBAC3C,QAAQ,GAAG,EAAE;oBACT,KAAK,MAAM;wBACP,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,UAAU,EAAE;4BACpC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;yBACjD;6BAAM;4BACH,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;yBAC/C;wBACD,MAAM;oBACV;wBACI,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;wBAC5C,MAAM;iBACb;aACJ;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACnB,CAAC;CAEJ;AAED,iBAAS,WAAW,CAAC"} \ No newline at end of file diff --git a/dist/Sinkdweller.test.d.ts b/dist/Sinkdweller.test.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist/Sinkdweller.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/dist/Sinkdweller.test.js b/dist/Sinkdweller.test.js new file mode 100644 index 0000000..1ff3d9f --- /dev/null +++ b/dist/Sinkdweller.test.js @@ -0,0 +1,77 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const Sinkdweller = require("./Sinkdweller"); +it('has a test harness', () => { + expect('x').toBe('x'); +}); +it('constructs without arguments', () => { + let fuzzer = new Sinkdweller(); + expect(fuzzer).toBeInstanceOf(Sinkdweller); +}); +it('synchronously fuzzes', () => { + let fuzzer = new Sinkdweller(); + let result = fuzzer.fuzzSync('foo'); + expect(result).toEqual(expect.any(String)); +}); +it('synchronously returns Buffer or String depending on what is expected', () => { + let fuzzer = new Sinkdweller(); + let stringInput = "foo"; + let bufferInput = Buffer.from("foo"); + let stringResult = fuzzer.fuzzSync(stringInput); + let bufferResult = fuzzer.fuzzSync(bufferInput); + expect(stringResult).toEqual(expect.any(String)); + expect(bufferResult).toEqual(expect.any(Buffer)); +}); +it('synchronously returns a string with a fixed seed function', () => { + let fuzzer = new Sinkdweller(); + fuzzer.setSeed(() => { + return 3; + }); + let result = fuzzer.fuzzSync('foo'); + expect(result).toBe('fono'); +}); +it('allows numeric seeds', () => { + let fuzzer = new Sinkdweller(); + fuzzer.setSeed(3); + let result = fuzzer.fuzzSync('foo'); + expect(result).toBe('fono'); +}); +it('properly uses a seed function', () => { + let fuzzer = new Sinkdweller(); + let iter = 0; + let sequence = [3, 4, 5]; + fuzzer.setSeed(() => { + let ret = sequence[iter]; + iter++; + return ret; + }); + let results = []; + for (let i = 0; i < 3; i++) { + results.push(fuzzer.fuzzSync('foo')); + } + expect(results).toEqual(['fono', 'ffoo', 'fon']); +}); +it('asynchronously works using callbacks', (done) => { + let fuzzer = new Sinkdweller(); + fuzzer.setSeed(3); + fuzzer.fuzz('foo', (err, result) => { + expect(err).toBeFalsy(); + expect(result).toBe('fono'); + done(); + }); +}); +it('asynchronously works with promise/async/await', () => __awaiter(this, void 0, void 0, function* () { + let fuzzer = new Sinkdweller(); + fuzzer.setSeed(3); + let result = yield fuzzer.fuzzAsync('foo'); + expect(result).toBe('fono'); +})); +//# sourceMappingURL=Sinkdweller.test.js.map \ No newline at end of file diff --git a/dist/Sinkdweller.test.js.map b/dist/Sinkdweller.test.js.map new file mode 100644 index 0000000..6478f84 --- /dev/null +++ b/dist/Sinkdweller.test.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Sink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,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,sCAAsC,EAAE,CAAC,IAAI,EAAE,EAAE;IAChD,IAAI,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;IAC/B,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAClB,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,GAAO,EAAE,MAAoB,EAAE,EAAE;QACjD,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC;QACxB,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC5B,IAAI,EAAE,CAAC;IACX,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,EAAE,CAAE,+CAA+C,EAAE,GAAS,EAAE;IAC5D,IAAI,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;IAC/B,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAClB,IAAI,MAAM,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC3C,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC,CAAA,CAAC,CAAC"} \ No newline at end of file diff --git a/package.json b/package.json index ec0a990..b6c9692 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sinkdweller", - "version": "1.0.5", + "version": "1.0.6", "description": "A TypeScript-based frontend to the radamsa fuzzer. No dependencies on most platforms.", "main": "dist/Sinkdweller.js", "scripts": { diff --git a/tsconfig.json b/tsconfig.json index c5227a3..e17eef1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,8 @@ { "compilerOptions": { "module": "commonjs", - "esModuleInterop": true, + "declaration": true, + "esModuleInterop": true, "target": "es6", "noImplicitAny": true, "moduleResolution": "node", @@ -18,4 +19,4 @@ "include": [ "src/**/*" ] -} \ No newline at end of file +}