chore(fuzz): import specific function

This commit is contained in:
hulkoba 2023-12-18 09:16:43 +01:00
parent e7b270b7c2
commit 2f05bd550e
No known key found for this signature in database
GPG Key ID: ACB6C4A3A4F2BE2F
8 changed files with 16 additions and 16 deletions

View File

@ -1,6 +1,6 @@
import { FuzzedDataProvider } from '@jazzer.js/core';
import openpgp from '../initOpenpgp.js';
import { createCleartextMessage } from 'openpgp';
const MAX_MESSAGE_LENGTH = 4096;
@ -10,6 +10,6 @@ const MAX_MESSAGE_LENGTH = 4096;
export function fuzz (inputData) {
const data = new FuzzedDataProvider(inputData);
const text = data.bufToPrintableString(inputData, 2, MAX_MESSAGE_LENGTH, 'utf-8');
return openpgp.createCleartextMessage({ text });
return createCleartextMessage({ text });
}

View File

@ -1,9 +1,9 @@
import openpgp from '../initOpenpgp.js';
import { createMessage } from 'openpgp';
/**
* @param { Buffer } inputData
*/
export function fuzz (inputData) {
return openpgp.createMessage({ binary: new Uint8Array(inputData) });
return createMessage({ binary: new Uint8Array(inputData) });
}

View File

@ -1,6 +1,6 @@
import { FuzzedDataProvider } from '@jazzer.js/core';
import openpgp from '../initOpenpgp.js';
import { createMessage } from 'openpgp';
const MAX_MESSAGE_LENGTH = 4096;
@ -9,5 +9,5 @@ const MAX_MESSAGE_LENGTH = 4096;
*/
export function fuzz (inputData) {
const data = new FuzzedDataProvider(inputData);
return openpgp.createMessage({ text: data.consumeString(MAX_MESSAGE_LENGTH, 'utf-8') });
return createMessage({ text: data.consumeString(MAX_MESSAGE_LENGTH, 'utf-8') });
}

View File

@ -1,6 +1,6 @@
import { FuzzedDataProvider } from '@jazzer.js/core';
import openpgp from '../initOpenpgp.js';
import { generateKey } from 'openpgp';
const MAX_NAME_LENGTH = 30;
const MAX_COMMENT_LENGTH = 500;
@ -14,7 +14,7 @@ export function fuzz (inputData) {
const asciiString = data.consumeString(MAX_COMMENT_LENGTH);
const utf8String = data.consumeString(MAX_NAME_LENGTH, 'utf-8');
return openpgp.generateKey({ userIDs: [
return generateKey({ userIDs: [
{ name: utf8String },
{ email: utf8String },
{ comment: asciiString },

View File

@ -1,6 +1,6 @@
import { FuzzedDataProvider } from '@jazzer.js/core';
import openpgp from '../initOpenpgp.js';
import { readKey } from 'openpgp';
const ignored = ['Misformed armored text'];
const MAX_MESSAGE_LENGTH = 4096;
@ -18,7 +18,7 @@ export function fuzz (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 })
return readKey({ armoredKey })
.catch(error => {
if (error.message && !ignoredError(error)) {
throw error;

View File

@ -1,4 +1,4 @@
import openpgp from '../initOpenpgp.js';
import { readKey } from 'openpgp';
const ignored = ['This message / key probably does not conform to a valid OpenPGP format'];
@ -12,7 +12,7 @@ function ignoredError(error) {
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 })
return readKey({ binaryKey })
.catch(error => {
if (error.message && !ignoredError(error)) {
throw error;

View File

@ -1,6 +1,6 @@
import { FuzzedDataProvider } from '@jazzer.js/core';
import openpgp from '../initOpenpgp.js';
import { readMessage } from 'openpgp';
const ignored = ['Misformed armored text'];
const MAX_MESSAGE_LENGTH = 4096;
@ -17,7 +17,7 @@ export function fuzz (inputData) {
const fuzzedText = data.consumeString(MAX_MESSAGE_LENGTH, 'utf-8');
const armoredMessage = `-----BEGIN PGP MESSAGE-----\n ${fuzzedText} -----END PGP MESSAGE-----`;
return openpgp.readMessage({ armoredMessage })
return readMessage({ armoredMessage })
.catch(error => {
if (error.message && !ignoredError(error)) {
throw error;

View File

@ -1,4 +1,4 @@
import openpgp from '../initOpenpgp.js';
import { readMessage } from 'openpgp';
const ignored = ['This message / key probably does not conform to a valid OpenPGP format'];
@ -12,7 +12,7 @@ function ignoredError(error) {
export function fuzz (inputData) {
const binaryMessage = new Uint8Array(`-----BEGIN PGP MESSAGE-----\n ${inputData.toString('base64')} -----END PGP MESSAGE-----`);
return openpgp.readMessage({ binaryMessage })
return readMessage({ binaryMessage })
.catch(error => {
if (error.message && !ignoredError(error)) {
throw error;