Download tasks/codeql_javascript_benchmark_top30_v1/morefixes-941abf85c9b7d820de47/patch.diff from Benchanything/checkerbench: direct link, hf CLI and curl.
- Browser
- Download file 2.72 kB
-
https://huggingface.co/datasets/Benchanything/checkerbench/resolve/main/tasks/codeql_javascript_benchmark_top30_v1/morefixes-941abf85c9b7d820de47/patch.diff
- Command line
-
hf download hf://datasets/Benchanything/checkerbench/tasks/codeql_javascript_benchmark_top30_v1/morefixes-941abf85c9b7d820de47/patch.diff
-
curl -L -o patch.diff https://huggingface.co/datasets/Benchanything/checkerbench/resolve/main/tasks/codeql_javascript_benchmark_top30_v1/morefixes-941abf85c9b7d820de47/patch.diff
2.72 kB
| diff --git a/lib/jwe/decrypt.js b/lib/jwe/decrypt.js | |
| index 9da8aead..358d084b 100644 | |
| --- a/lib/jwe/decrypt.js | |
| +++ b/lib/jwe/decrypt.js | |
| const validateAlgorithms = (algorithms, option) => { | |
| /* | |
| * @public | |
| */ | |
| -const jweDecrypt = (skipValidateHeaders, serialization, jwe, key, { crit = [], complete = false, keyManagementAlgorithms, contentEncryptionAlgorithms, maxPBES2Count = 10000 } = {}) => { | |
| +const jweDecrypt = (skipValidateHeaders, serialization, jwe, key, { crit = [], complete = false, keyManagementAlgorithms, contentEncryptionAlgorithms, maxPBES2Count = 10000, inflateRawSyncLimit = 250000 } = {}) => { | |
| key = getKey(key, true) | |
| keyManagementAlgorithms = validateAlgorithms(keyManagementAlgorithms, 'keyManagementAlgorithms') | |
| const jweDecrypt = (skipValidateHeaders, serialization, jwe, key, { crit = [], c | |
| let cleartext = decrypt(enc, cek, base64url.decodeToBuffer(ciphertext), { iv, tag, aad: adata }) | |
| if (opts.zip) { | |
| - cleartext = inflateRawSync(cleartext) | |
| + cleartext = inflateRawSync(cleartext, { maxOutputLength: inflateRawSyncLimit }) | |
| } | |
| if (complete) { | |
| diff --git a/test/jwe/sanity.test.js b/test/jwe/sanity.test.js | |
| index fd8a0837..e83d8c78 100644 | |
| --- a/test/jwe/sanity.test.js | |
| +++ b/test/jwe/sanity.test.js | |
| const test = require('ava') | |
| +const crypto = require('crypto') | |
| const base64url = require('../../lib/help/base64url') | |
| const { JWKS, JWK: { generateSync }, JWE, errors } = require('../..') | |
| if (!('electron' in process.versions)) { | |
| }, { instanceOf: errors.JWEInvalid, message: 'JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds' }) | |
| }) | |
| } | |
| + | |
| +test('Compressed JWE output length limit', t => { | |
| + const k = generateSync('oct', 256) | |
| + { | |
| + const jwe = JWE.encrypt(crypto.randomBytes(250000), k, { alg: 'dir', enc: 'A128CBC-HS256', zip: 'DEF' }) | |
| + t.notThrows(() => { | |
| + JWE.decrypt(jwe, k) | |
| + }) | |
| + } | |
| + { | |
| + const jwe = JWE.encrypt(crypto.randomBytes(250000 + 1), k, { alg: 'dir', enc: 'A128CBC-HS256', zip: 'DEF' }) | |
| + t.throws(() => { | |
| + JWE.decrypt(jwe, k) | |
| + }) | |
| + } | |
| + { | |
| + const jwe = JWE.encrypt(crypto.randomBytes(1001), k, { alg: 'dir', enc: 'A128CBC-HS256', zip: 'DEF' }) | |
| + t.throws(() => { | |
| + JWE.decrypt(jwe, k, { inflateRawSyncLimit: 1000 }) | |
| + }) | |
| + } | |
| +}) | |
| diff --git a/types/index.d.ts b/types/index.d.ts | |
| index 30e146a0..ec330822 100644 | |
| --- a/types/index.d.ts | |
| +++ b/types/index.d.ts | |
| export namespace JWE { | |
| contentEncryptionAlgorithms?: string[]; | |
| keyManagementAlgorithms?: string[]; | |
| maxPBES2Count?: number; | |
| + inflateRawSyncLimit?: number; | |
| } | |
| interface completeDecrypt { | |