Add crypto-inventory: a cryptographic inventory of source code as a CycloneDX 1.6 CBOM, with linear cost on hostile input; PKI DER messages in English
This commit is contained in:
1 parent
7d814d1bb8
commit
0f081f0847
49 files changed
+4342
-33
No files matched your search
@@ -0,0 +1,14 @@
|
||||
// MessageDigest.getInstance("MD5") intr-un comentariu nu e o folosire.
|
||||
package fixturi;
|
||||
|
||||
public class Comentarii {
|
||||
/* Cipher.getInstance("DES") intr-un comentariu bloc */
|
||||
/**
|
||||
* Signature.getInstance("SHA1withRSA") in Javadoc.
|
||||
*/
|
||||
private final String doc = "KeyPairGenerator.getInstance(\"RSA\") in a string";
|
||||
|
||||
public String doc() {
|
||||
return doc;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Fixtura negativa Go: niciun import criptografic.
|
||||
package fixturi
|
||||
|
||||
/*
|
||||
import "crypto/md5"
|
||||
*/
|
||||
|
||||
// md5.Sum(data) intr-un comentariu nu e o folosire.
|
||||
func Nimic() string {
|
||||
return "crypto/rsa rsa.GenerateKey(rand.Reader, 1024)"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// Fixtura negativa: fisierul importa node:crypto doar pentru UUID-uri. Comentariile pomenesc
|
||||
// API-uri reale; niciunul nu e o folosire si scanerul trebuie sa dea ZERO gasiri.
|
||||
import crypto from 'node:crypto';
|
||||
|
||||
// crypto.createHash('md5') intr-un comentariu nu e o folosire.
|
||||
// const k = crypto.generateKeyPairSync('rsa', { modulusLength: 1024 });
|
||||
/* crypto.createCipheriv('des-ede3-cbc', key, iv) intr-un comentariu bloc */
|
||||
/**
|
||||
* Exemplu din documentatie: crypto.createSign('RSA-SHA1').
|
||||
* RSA, ECDSA, secp256k1 si X25519 sunt aici doar cuvinte.
|
||||
*/
|
||||
export function id() {
|
||||
return crypto.randomUUID(); // crypto.createHmac('sha1', k) tot comentariu
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
"""Modul fara criptografie.
|
||||
|
||||
Documentatia pomeneste rsa.generate_private_key(public_exponent=65537, key_size=1024)
|
||||
si hashlib.md5(data), dar nu le cheama.
|
||||
"""
|
||||
import hashlib
|
||||
|
||||
|
||||
def f(x):
|
||||
"""Returneaza x. Nu foloseste hashlib.sha1(x)."""
|
||||
# hashlib.md5(x) intr-un comentariu nu e o folosire
|
||||
text = "hashlib.md5 apare aici doar ca text"
|
||||
return x, text, hashlib
|
||||
@@ -0,0 +1,9 @@
|
||||
export function sign(x) {
|
||||
return Math.sign(x);
|
||||
}
|
||||
|
||||
export function createHash(n) {
|
||||
return { n, hash: n * 31 };
|
||||
}
|
||||
|
||||
export const rezultat = [sign(-3), createHash(7)].map((v) => JSON.stringify(v));
|
||||
@@ -0,0 +1,9 @@
|
||||
import crypto from 'node:crypto';
|
||||
|
||||
export const doc = "Call crypto.createHash('md5') to hash (documentation string).";
|
||||
export const tpl = `Use crypto.createCipheriv('des-ede3-cbc', key, iv) at ${Date.now()}`;
|
||||
export const eticheta = 'crypto.generateKeyPairSync("rsa", { modulusLength: 1024 })';
|
||||
export const re = /createHash\('sha1'\)/;
|
||||
export function id() {
|
||||
return crypto.randomUUID();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// Fixtura: algoritmi dati prin variabile care NU se pot rezolva static. Trebuie "unknown", nu ghicit.
|
||||
import crypto from 'node:crypto';
|
||||
|
||||
let alg = 'md5';
|
||||
alg = 'sha256';
|
||||
|
||||
export function h(data, algDinApel, opts) {
|
||||
const a = crypto.createHash(alg); // EXPECT: createHash | unknown
|
||||
const b = crypto.createHash(algDinApel); // EXPECT: createHash | unknown
|
||||
const c = crypto.createCipheriv(opts.cipher, opts.key, opts.iv); // EXPECT: createCipheriv | unknown
|
||||
return [a, b, c, data];
|
||||
}
|
||||
Reference in new issue
Block a user