Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fair-lemons-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nodesecure/js-x-ray": minor
---

feat(js-x-ray): detect more sync IO method for crypto module
5 changes: 5 additions & 0 deletions workspaces/js-x-ray/src/probes/isSyncIO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const kSyncIOIdentifierOrMemberExps = [
"crypto.pbkdf2Sync",
"crypto.scryptSync",
"crypto.generateKeyPairSync",
"crypto.generateKeySync",
"crypto.hkdfSync",
"crypto.randomFillSync",
"crypto.checkPrimeSync",
"crypto.argon2Sync",
"fs.readFileSync",
"fs.writeFileSync",
"fs.appendFileSync",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { argon2Sync } from "crypto";

const parameters = {
message: 'password',
nonce: randomBytes(16),
parallelism: 4,
tagLength: 64,
memory: 65536,
passes: 3,
};


argon2Sync('argon2id', parameters);

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { checkPrimeSync } from "crypto";

checkPrimeSync(17n);

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { generateKeySync } from "crypto";

generateKeySync('hmac', { length: 512 });

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { hkdfSync } from "crypto";

hkdfSync('sha512', 'key', 'salt', 'info', 64);

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Buffer } from "node:buffer";
import { randomFillSync } from "crypto";


const buf = Buffer.alloc(10);
randomFillSync(buf).toString('hex');

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import crypto from "crypto";

const parameters = {
message: 'password',
nonce: randomBytes(16),
parallelism: 4,
tagLength: 64,
memory: 65536,
passes: 3,
};

const argon2Sync = crypto.argon2Sync;

argon2Sync('argon2id', parameters);

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import crypto from "crypto";

const checkPrimeSync = crypto.checkPrimeSync;

checkPrimeSync(17n);

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import crypto from "crypto";

const generateKeySync = crypto.generateKeySync;


generateKeySync('hmac', { length: 512 });

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import crypto from 'crypto';

const hkdfSync = crypto.hkdfSync;

hkdfSync('sha512', 'key', 'salt', 'info', 64);

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Buffer } from "node:buffer";
import crypto from "crypto";

const randomFillSync = crypto.randomFillSync;

const buf = Buffer.alloc(10);
randomFillSync(buf).toString('hex');