forked from openpgpjs/openpgpjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(fuzz): turn everything into esm
since coverage does not work as expected at all, we can use esm. So if jazzer at some point, add esm support for esm, we can easily add it
- Loading branch information
Showing
18 changed files
with
167 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { FuzzedDataProvider } from '@jazzer.js/core'; | ||
|
||
import openpgp from '../initOpenpgp.js'; | ||
|
||
const MAX_MESSAGE_LENGTH = 9000; | ||
|
||
/** | ||
* @param { Buffer } inputData | ||
*/ | ||
export function fuzz (inputData) { | ||
const data = new FuzzedDataProvider(inputData); | ||
const text = data.bufToPrintableString(inputData, 2, MAX_MESSAGE_LENGTH, 'utf-8'); | ||
return openpgp.createCleartextMessage({ text }); | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import openpgp from '../initOpenpgp.js'; | ||
|
||
/** | ||
* @param { Buffer } inputData | ||
*/ | ||
export function fuzz (inputData) { | ||
return openpgp.createMessage({ binary: new Uint8Array(inputData) }); | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { FuzzedDataProvider } from '@jazzer.js/core'; | ||
|
||
import openpgp from '../initOpenpgp.js'; | ||
|
||
const MAX_MESSAGE_LENGTH = 9000; | ||
|
||
/** | ||
* @param { Buffer } inputData | ||
*/ | ||
export function fuzz (inputData) { | ||
const data = new FuzzedDataProvider(inputData); | ||
return openpgp.createMessage({ text: data.consumeString(MAX_MESSAGE_LENGTH, 'utf-8') }); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { FuzzedDataProvider } from '@jazzer.js/core'; | ||
|
||
import openpgp from '../initOpenpgp.js'; | ||
|
||
const MAX_NAME_LENGTH = 30; | ||
const MAX_COMMENT_LENGTH = 500; | ||
|
||
/** | ||
* @param { Buffer } inputData | ||
*/ | ||
export function fuzz (inputData) { | ||
|
||
const data = new FuzzedDataProvider(inputData); | ||
const asciiString = data.consumeString(MAX_COMMENT_LENGTH); | ||
const utf8String = data.consumeString(MAX_NAME_LENGTH, 'utf-8'); | ||
|
||
return openpgp.generateKey({ userIDs: [ | ||
{ name: utf8String }, | ||
{ email: utf8String }, | ||
{ comment: asciiString }, | ||
{ name: utf8String, email: utf8String, comment: asciiString } | ||
], | ||
passphrase: asciiString, | ||
format: 'object' }); | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { FuzzedDataProvider } from '@jazzer.js/core'; | ||
|
||
import openpgp from '../initOpenpgp.js'; | ||
|
||
const ignored = ['Misformed armored text']; | ||
const MAX_MESSAGE_LENGTH = 9000; | ||
|
||
function ignoredError(error) { | ||
return ignored.some(message => error.message.includes(message)); | ||
} | ||
|
||
/** | ||
* @param { Buffer } inputData | ||
*/ | ||
export function fuzz (inputData) { | ||
|
||
const data = new FuzzedDataProvider(inputData); | ||
const fuzzedText = data.consumeString(MAX_MESSAGE_LENGTH, 'utf-8'); | ||
const armoredKey = `-----BEGIN PGP PRIVATE KEY BLOCK-----\n ${fuzzedText} -----END PGP PRIVATE KEY BLOCK-----`; | ||
|
||
return openpgp.readKey({ armoredKey }) | ||
.catch(error => { | ||
if (error.message && !ignoredError(error)) { | ||
throw error; | ||
} | ||
}); | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import openpgp from '../initOpenpgp.js'; | ||
|
||
const ignored = ['This message / key probably does not conform to a valid OpenPGP format']; | ||
|
||
function ignoredError(error) { | ||
return ignored.some(message => error.message.includes(message)); | ||
} | ||
|
||
/** | ||
* @param { Buffer } inputData | ||
*/ | ||
export function fuzz (inputData) { | ||
const binaryKey = new Uint8Array(`-----BEGIN PGP PRIVATE KEY BLOCK-----\n ${inputData.toString('base64')} -----END PGP PRIVATE KEY BLOCK-----`); | ||
|
||
return openpgp.readKey({ binaryKey }) | ||
.catch(error => { | ||
if (error.message && !ignoredError(error)) { | ||
throw error; | ||
} | ||
}); | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import openpgp from '../initOpenpgp.js'; | ||
|
||
const ignored = ['This message / key probably does not conform to a valid OpenPGP format']; | ||
|
||
function ignoredError(error) { | ||
return ignored.some(message => error.message.includes(message)); | ||
} | ||
|
||
/** | ||
* @param { Buffer } inputData | ||
*/ | ||
export function fuzz (inputData) { | ||
const binaryMessage = new Uint8Array(`-----BEGIN PGP MESSAGE-----\n ${inputData.toString('base64')} -----END PGP MESSAGE-----`); | ||
|
||
return openpgp.readMessage({ binaryMessage }) | ||
.catch(error => { | ||
if (error.message && !ignoredError(error)) { | ||
throw error; | ||
} | ||
}); | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { FuzzedDataProvider } from '@jazzer.js/core'; | ||
|
||
import openpgp from '../initOpenpgp.js'; | ||
|
||
const ignored = ['Misformed armored text']; | ||
const MAX_MESSAGE_LENGTH = 9000; | ||
|
||
function ignoredError(error) { | ||
return ignored.some(message => error.message.includes(message)); | ||
} | ||
|
||
/** | ||
* @param { Buffer } inputData | ||
*/ | ||
export function fuzz (inputData) { | ||
const data = new FuzzedDataProvider(inputData); | ||
const fuzzedText = data.consumeString(MAX_MESSAGE_LENGTH, 'utf-8'); | ||
const armoredMessage = `-----BEGIN PGP MESSAGE-----\n ${fuzzedText} -----END PGP MESSAGE-----`; | ||
|
||
return openpgp.readMessage({ armoredMessage }) | ||
.catch(error => { | ||
if (error.message && !ignoredError(error)) { | ||
throw error; | ||
} | ||
}); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters