From 9a35febe80df3c4e36b53ccfa8dea903aa55093b Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Mon, 3 Mar 2025 17:20:58 +0000
Subject: [PATCH 001/534] Rust: Query framework and basic tests.
---
.../CWE-798/HardcodedCryptographicValue.ql | 21 ++++++
.../HardcodedCryptographicValue.expected | 0
.../CWE-798/HardcodedCryptographicValue.qlref | 2 +
.../query-tests/security/CWE-798/options.yml | 6 ++
.../security/CWE-798/test_cipher.rs | 66 +++++++++++++++++++
5 files changed, 95 insertions(+)
create mode 100644 rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
create mode 100644 rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
create mode 100644 rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.qlref
create mode 100644 rust/ql/test/query-tests/security/CWE-798/options.yml
create mode 100644 rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
diff --git a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
new file mode 100644
index 00000000000..717831bba2b
--- /dev/null
+++ b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
@@ -0,0 +1,21 @@
+/**
+ * @name Hard-coded cryptographic value
+ * @description Using hardcoded keys, passwords, salts or initialization
+ * vectors is not secure.
+ * @kind problem
+ * @problem.severity warning
+ * @security-severity TODO
+ * @precision high
+ * @id rust/hardcoded-crytographic-value
+ * @tags security
+ * external/cwe/cwe-259
+ * external/cwe/cwe-321
+ * external/cwe/cwe-798
+ * external/cwe/cwe-1204
+ */
+
+import rust
+
+from Locatable e
+where none()
+select e, ""
diff --git a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.qlref b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.qlref
new file mode 100644
index 00000000000..99053e9bf1a
--- /dev/null
+++ b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.qlref
@@ -0,0 +1,2 @@
+query: queries/security/CWE-798/HardcodedCryptographicValue.ql
+postprocess: utils/test/InlineExpectationsTestQuery.ql
diff --git a/rust/ql/test/query-tests/security/CWE-798/options.yml b/rust/ql/test/query-tests/security/CWE-798/options.yml
new file mode 100644
index 00000000000..07dc5e9922e
--- /dev/null
+++ b/rust/ql/test/query-tests/security/CWE-798/options.yml
@@ -0,0 +1,6 @@
+qltest_cargo_check: true
+qltest_dependencies:
+ - cipher = { version = "0.4.4" }
+ - rabbit = { version = "0.4.1" }
+ - aes = { version = "0.8.4" }
+ - cfb-mode = { version = "0.8.2" }
diff --git a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
new file mode 100644
index 00000000000..532fe523c07
--- /dev/null
+++ b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
@@ -0,0 +1,66 @@
+
+use cipher::{consts::*, StreamCipher, AsyncStreamCipher, KeyInit, KeyIvInit, BlockEncrypt};
+use rabbit::{Rabbit, RabbitKeyOnly};
+use aes::Aes256;
+
+// --- tests ---
+
+fn test_stream_cipher_rabbit(
+ key: &[u8;16], iv: &[u8;16], plaintext: &str
+) {
+ let mut data = plaintext.as_bytes().to_vec();
+
+ // rabbit
+
+ let mut rabbit_cipher1 = RabbitKeyOnly::new(rabbit::Key::from_slice(key));
+ rabbit_cipher1.apply_keystream(&mut data);
+
+ let const1: &[u8;16] = &[0u8;16]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let mut rabbit_cipher2 = RabbitKeyOnly::new(rabbit::Key::from_slice(const1));
+ rabbit_cipher2.apply_keystream(&mut data);
+
+ let mut rabbit_cipher3 = Rabbit::new(rabbit::Key::from_slice(key), rabbit::Iv::from_slice(iv));
+ rabbit_cipher3.apply_keystream(&mut data);
+
+ let const2: &[u8;16] = &[0u8;16]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let mut rabbit_cipher4 = Rabbit::new(rabbit::Key::from_slice(const2), rabbit::Iv::from_slice(iv));
+ rabbit_cipher4.apply_keystream(&mut data);
+
+ let const3: &[u8;16] = &[0u8;16]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let mut rabbit_cipher5 = Rabbit::new(rabbit::Key::from_slice(key), rabbit::Iv::from_slice(const3));
+ rabbit_cipher5.apply_keystream(&mut data);
+
+ let const4: &[u8;16] = &[0u8;16]; // (unused, so good)
+}
+
+fn test_block_cipher_aes(
+ key: &[u8], iv: &[u8], key256: &[u8;32],
+ block128: &mut [u8;16], input: &[u8], output: &mut [u8]
+) {
+ // aes
+
+ let aes_cipher1 = Aes256::new(key256.into());
+ aes_cipher1.encrypt_block(block128.into());
+
+ let const1 = &[0u8;32]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let aes_cipher2 = Aes256::new(const1.into());
+ aes_cipher2.encrypt_block(block128.into());
+
+ let aes_cipher3 = Aes256::new_from_slice(key256).unwrap();
+ aes_cipher3.encrypt_block(block128.into());
+
+ let const2 = &[0u8;32]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let aes_cipher4 = Aes256::new_from_slice(const2).unwrap();
+ aes_cipher4.encrypt_block(block128.into());
+
+ let aes_cipher5 = cfb_mode::Encryptor::::new(key.into(), iv.into());
+ _ = aes_cipher5.encrypt_b2b(input, output).unwrap();
+
+ let const3 = &[0u8;32]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let aes_cipher6 = cfb_mode::Encryptor::::new(const3.into(), iv.into());
+ _ = aes_cipher6.encrypt_b2b(input, output).unwrap();
+
+ let const4 = &[0u8; 16]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let aes_cipher7 = cfb_mode::Encryptor::::new(key.into(), const4.into());
+ _ = aes_cipher7.encrypt_b2b(input, output).unwrap();
+}
From bd75f0187b88823b41dd9767b05a081306f29b61 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Wed, 5 Mar 2025 18:44:59 +0000
Subject: [PATCH 002/534] Rust: More test cases.
---
.../query-tests/security/CWE-798/options.yml | 2 +
.../security/CWE-798/test_cipher.rs | 92 ++++++++++++++++---
2 files changed, 82 insertions(+), 12 deletions(-)
diff --git a/rust/ql/test/query-tests/security/CWE-798/options.yml b/rust/ql/test/query-tests/security/CWE-798/options.yml
index 07dc5e9922e..aff715ea271 100644
--- a/rust/ql/test/query-tests/security/CWE-798/options.yml
+++ b/rust/ql/test/query-tests/security/CWE-798/options.yml
@@ -3,4 +3,6 @@ qltest_dependencies:
- cipher = { version = "0.4.4" }
- rabbit = { version = "0.4.1" }
- aes = { version = "0.8.4" }
+ - aes-gcm = { version = "0.10.3" }
- cfb-mode = { version = "0.8.2" }
+ - base64 = { version = "0.22.1" }
diff --git a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
index 532fe523c07..748b9f3e012 100644
--- a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
+++ b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
@@ -22,19 +22,40 @@ fn test_stream_cipher_rabbit(
let mut rabbit_cipher3 = Rabbit::new(rabbit::Key::from_slice(key), rabbit::Iv::from_slice(iv));
rabbit_cipher3.apply_keystream(&mut data);
- let const2: &[u8;16] = &[0u8;16]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
- let mut rabbit_cipher4 = Rabbit::new(rabbit::Key::from_slice(const2), rabbit::Iv::from_slice(iv));
+ let const4: &[u8;16] = &[0u8;16]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let mut rabbit_cipher4 = Rabbit::new(rabbit::Key::from_slice(const4), rabbit::Iv::from_slice(iv));
rabbit_cipher4.apply_keystream(&mut data);
- let const3: &[u8;16] = &[0u8;16]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
- let mut rabbit_cipher5 = Rabbit::new(rabbit::Key::from_slice(key), rabbit::Iv::from_slice(const3));
+ let const5: &[u8;16] = &[0u8;16]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let mut rabbit_cipher5 = Rabbit::new(rabbit::Key::from_slice(key), rabbit::Iv::from_slice(const5));
rabbit_cipher5.apply_keystream(&mut data);
- let const4: &[u8;16] = &[0u8;16]; // (unused, so good)
+ // various expressions of constant arrays
+
+ let const6: &[u8;16] = &[0u8;16]; // (unused, so good)
+
+ let const7: [u8;16] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let mut rabbit_cipher7 = RabbitKeyOnly::new(rabbit::Key::from_slice(&const7));
+ rabbit_cipher7.apply_keystream(&mut data);
+
+ let const8: &[u8;16] = &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let mut rabbit_cipher8 = RabbitKeyOnly::new(rabbit::Key::from_slice(const8));
+ rabbit_cipher8.apply_keystream(&mut data);
+
+ let const9: [u16;8] = [0, 0, 0, 0, 0, 0, 0, 0]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let const9_conv = unsafe { const9.align_to::().1 }; // convert [u16;8] -> [u8;8]
+ let mut rabbit_cipher9 = RabbitKeyOnly::new(rabbit::Key::from_slice(const9_conv));
+ rabbit_cipher9.apply_keystream(&mut data);
+
+ let const10: [u8;16] = unsafe { std::mem::zeroed() }; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let mut rabbit_cipher10 = RabbitKeyOnly::new(rabbit::Key::from_slice(&const10));
+ rabbit_cipher10.apply_keystream(&mut data);
}
+use base64::Engine;
+
fn test_block_cipher_aes(
- key: &[u8], iv: &[u8], key256: &[u8;32],
+ key: &[u8], iv: &[u8], key256: &[u8;32], key_str: &str,
block128: &mut [u8;16], input: &[u8], output: &mut [u8]
) {
// aes
@@ -42,8 +63,8 @@ fn test_block_cipher_aes(
let aes_cipher1 = Aes256::new(key256.into());
aes_cipher1.encrypt_block(block128.into());
- let const1 = &[0u8;32]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
- let aes_cipher2 = Aes256::new(const1.into());
+ let const2 = &[0u8;32]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let aes_cipher2 = Aes256::new(const2.into());
aes_cipher2.encrypt_block(block128.into());
let aes_cipher3 = Aes256::new_from_slice(key256).unwrap();
@@ -56,11 +77,58 @@ fn test_block_cipher_aes(
let aes_cipher5 = cfb_mode::Encryptor::::new(key.into(), iv.into());
_ = aes_cipher5.encrypt_b2b(input, output).unwrap();
- let const3 = &[0u8;32]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
- let aes_cipher6 = cfb_mode::Encryptor::::new(const3.into(), iv.into());
+ let const6 = &[0u8;32]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let aes_cipher6 = cfb_mode::Encryptor::::new(const6.into(), iv.into());
_ = aes_cipher6.encrypt_b2b(input, output).unwrap();
- let const4 = &[0u8; 16]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
- let aes_cipher7 = cfb_mode::Encryptor::::new(key.into(), const4.into());
+ let const7 = &[0u8; 16]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let aes_cipher7 = cfb_mode::Encryptor::::new(key.into(), const7.into());
_ = aes_cipher7.encrypt_b2b(input, output).unwrap();
+
+ // various string conversions
+
+ let key8: &[u8] = key_str.as_bytes();
+ let aes_cipher8 = cfb_mode::Encryptor::::new(key8.into(), iv.into());
+ _ = aes_cipher8.encrypt_b2b(input, output).unwrap();
+
+ let key9: &[u8] = "1234567890123456".as_bytes(); // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let aes_cipher9 = cfb_mode::Encryptor::::new(key9.into(), iv.into());
+ _ = aes_cipher9.encrypt_b2b(input, output).unwrap();
+
+ let key10: [u8; 32] = match base64::engine::general_purpose::STANDARD.decode(key_str) {
+ Ok(x) => x.try_into().unwrap(),
+ Err(_) => "1234567890123456".as_bytes().try_into().unwrap() // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ };
+ let aes_cipher10 = Aes256::new(&key10.into());
+ aes_cipher10.encrypt_block(block128.into());
+
+ if let Ok(const11) = base64::engine::general_purpose::STANDARD.decode("1234567890123456") { // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let key11: [u8; 32] = const11.try_into().unwrap();
+ let aes_cipher11 = Aes256::new(&key11.into());
+ aes_cipher11.encrypt_block(block128.into());
+ }
+}
+
+use aes_gcm::aead::{Aead, AeadCore, OsRng};
+use aes_gcm::{Aes256Gcm, Key, Nonce};
+
+fn test_aes_gcm(
+) {
+ // aes (GCM)
+
+ let key1 = Aes256Gcm::generate_key(aes_gcm::aead::OsRng);
+ let nonce1 = Aes256Gcm::generate_nonce(aes_gcm::aead::OsRng);
+ let cipher1 = Aes256Gcm::new(&key1);
+ let _ = cipher1.encrypt(&nonce1, b"plaintext".as_ref()).unwrap();
+
+ let key2: [u8;32] = [0;32]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let nonce2 = [0;12]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let cipher2 = Aes256Gcm::new(&key2.into());
+ let _ = cipher2.encrypt(&nonce2.into(), b"plaintext".as_ref()).unwrap();
+
+ let key3_array: &[u8;32] = &[0xff;32]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let key3 = Key::::from_slice(key3_array);
+ let nonce3: [u8;12] = [0xff;12]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let cipher3 = Aes256Gcm::new(&key3);
+ let _ = cipher3.encrypt(&nonce3.into(), b"plaintext".as_ref()).unwrap();
}
From 9fb00daeecb423f2b1beab21472dc40dd35eb0c8 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Mon, 3 Mar 2025 19:43:55 +0000
Subject: [PATCH 003/534] Rust: Implement the query (with one source, one sink
model).
---
.../rustcrypto/rustcrypto.model.yml | 1 +
.../HardcodedCryptographicValueExtensions.qll | 57 +++++++++++++++++++
.../CWE-798/HardcodedCryptographicValue.ql | 37 ++++++++++--
.../HardcodedCryptographicValue.expected | 16 ++++++
.../security/CWE-798/test_cipher.rs | 4 +-
5 files changed, 109 insertions(+), 6 deletions(-)
create mode 100644 rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
diff --git a/rust/ql/lib/codeql/rust/frameworks/rustcrypto/rustcrypto.model.yml b/rust/ql/lib/codeql/rust/frameworks/rustcrypto/rustcrypto.model.yml
index fe3fd67a8fd..baf21e9d6cc 100644
--- a/rust/ql/lib/codeql/rust/frameworks/rustcrypto/rustcrypto.model.yml
+++ b/rust/ql/lib/codeql/rust/frameworks/rustcrypto/rustcrypto.model.yml
@@ -8,3 +8,4 @@ extensions:
- ["repo:https://github.com/RustCrypto/traits:digest", "<_ as crate::digest::Digest>::chain_update", "Argument[0]", "hasher-input", "manual"]
- ["repo:https://github.com/RustCrypto/traits:digest", "<_ as crate::digest::Digest>::digest", "Argument[0]", "hasher-input", "manual"]
- ["repo:https://github.com/stainless-steel/md5:md5", "crate::compute", "Argument[0]", "hasher-input", "manual"]
+ - ["repo:https://github.com/RustCrypto/traits:crypto-common", "crate::KeyInit::new_from_slice", "Argument[0]", "credentials-key", "manual"]
diff --git a/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll b/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
new file mode 100644
index 00000000000..006f4fd8139
--- /dev/null
+++ b/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
@@ -0,0 +1,57 @@
+/**
+ * Provides classes and predicates for reasoning about hardcoded cryptographic value
+ * vulnerabilities.
+ */
+
+import rust
+private import codeql.rust.dataflow.DataFlow
+private import codeql.rust.dataflow.internal.DataFlowImpl
+private import codeql.rust.security.SensitiveData
+
+/**
+ * Provides default sources, sinks and barriers for detecting hardcoded cryptographic
+ * value vulnerabilities, as well as extension points for adding your own.
+ */
+module HardcodedCryptographicValue {
+ /**
+ * A data flow source for hardcoded cryptographic value vulnerabilities.
+ */
+ abstract class Source extends DataFlow::Node { }
+
+ /**
+ * A data flow sink for hardcoded cryptographic value vulnerabilities.
+ */
+ abstract class Sink extends DataFlow::Node {
+ /**
+ * Gets the kind of credential this sink is interpreted as,
+ * for example "password", "key", "iv", "salt".
+ */
+ abstract string getKind();
+ }
+
+ /**
+ * A barrier for hardcoded cryptographic value vulnerabilities.
+ */
+ abstract class Barrier extends DataFlow::Node { }
+
+ /**
+ * A literal, considered as a flow source.
+ */
+ private class LiteralSource extends Source {
+ LiteralSource() { this.asExpr().getExpr() instanceof LiteralExpr }
+ }
+
+ /**
+ * A sink for hardcoded cryptographic value from model data.
+ */
+ private class ModelsAsDataSinks extends Sink {
+ string kind;
+
+ ModelsAsDataSinks() {
+ kind = ["password", "key", "iv", "salt"] and
+ sinkNode(this, "credentials-" + kind)
+ }
+
+ override string getKind() { result = kind }
+ }
+}
diff --git a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
index 717831bba2b..2ec8ea8c257 100644
--- a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
+++ b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
@@ -2,7 +2,7 @@
* @name Hard-coded cryptographic value
* @description Using hardcoded keys, passwords, salts or initialization
* vectors is not secure.
- * @kind problem
+ * @kind path-problem
* @problem.severity warning
* @security-severity TODO
* @precision high
@@ -15,7 +15,36 @@
*/
import rust
+import codeql.rust.security.HardcodedCryptographicValueExtensions
+import codeql.rust.dataflow.DataFlow
+import codeql.rust.dataflow.TaintTracking
+import codeql.rust.dataflow.internal.DataFlowImpl
-from Locatable e
-where none()
-select e, ""
+/**
+ * A taint-tracking configuration for hardcoded cryptographic value vulnerabilities.
+ */
+module HardcodedCryptographicValueConfig implements DataFlow::ConfigSig {
+ import HardcodedCryptographicValue
+
+ predicate isSource(DataFlow::Node source) { source instanceof Source }
+
+ predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
+
+ predicate isBarrier(DataFlow::Node barrier) { barrier instanceof Barrier }
+
+ predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
+ // flow out from reference content at sinks.
+ isSink(node) and
+ c.getAReadContent() instanceof ReferenceContent
+ }
+}
+
+module HardcodedCryptographicValueFlow = TaintTracking::Global;
+
+import HardcodedCryptographicValueFlow::PathGraph
+
+from
+ HardcodedCryptographicValueFlow::PathNode source, HardcodedCryptographicValueFlow::PathNode sink
+where HardcodedCryptographicValueFlow::flowPath(source, sink)
+select source.getNode(), source, sink, "This hard-coded value is used as $@.", sink,
+ sink.getNode().(HardcodedCryptographicValueConfig::Sink).getKind()
diff --git a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
index e69de29bb2d..4e3e67e41e0 100644
--- a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
+++ b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
@@ -0,0 +1,16 @@
+#select
+| test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:74:23:74:44 | ...::new_from_slice | This hard-coded value is used as $@. | test_cipher.rs:74:23:74:44 | ...::new_from_slice | key |
+edges
+| test_cipher.rs:73:9:73:14 | const2 [&ref, element] | test_cipher.rs:74:46:74:51 | const2 [&ref, element] | provenance | |
+| test_cipher.rs:73:18:73:26 | &... [&ref, element] | test_cipher.rs:73:9:73:14 | const2 [&ref, element] | provenance | |
+| test_cipher.rs:73:19:73:26 | [0u8; 32] [element] | test_cipher.rs:73:18:73:26 | &... [&ref, element] | provenance | |
+| test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:73:19:73:26 | [0u8; 32] [element] | provenance | |
+| test_cipher.rs:74:46:74:51 | const2 [&ref, element] | test_cipher.rs:74:23:74:44 | ...::new_from_slice | provenance | MaD:54 Sink:MaD:54 Sink:MaD:54 |
+nodes
+| test_cipher.rs:73:9:73:14 | const2 [&ref, element] | semmle.label | const2 [&ref, element] |
+| test_cipher.rs:73:18:73:26 | &... [&ref, element] | semmle.label | &... [&ref, element] |
+| test_cipher.rs:73:19:73:26 | [0u8; 32] [element] | semmle.label | [0u8; 32] [element] |
+| test_cipher.rs:73:20:73:22 | 0u8 | semmle.label | 0u8 |
+| test_cipher.rs:74:23:74:44 | ...::new_from_slice | semmle.label | ...::new_from_slice |
+| test_cipher.rs:74:46:74:51 | const2 [&ref, element] | semmle.label | const2 [&ref, element] |
+subpaths
diff --git a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
index 748b9f3e012..cfd07d688a1 100644
--- a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
+++ b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
@@ -70,8 +70,8 @@ fn test_block_cipher_aes(
let aes_cipher3 = Aes256::new_from_slice(key256).unwrap();
aes_cipher3.encrypt_block(block128.into());
- let const2 = &[0u8;32]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
- let aes_cipher4 = Aes256::new_from_slice(const2).unwrap();
+ let const2 = &[0u8;32]; // $ Alert[rust/hardcoded-crytographic-value]
+ let aes_cipher4 = Aes256::new_from_slice(const2).unwrap(); // $ Sink
aes_cipher4.encrypt_block(block128.into());
let aes_cipher5 = cfb_mode::Encryptor::::new(key.into(), iv.into());
From a6e106e025ad51c11f8fe4c5abef38c65317b4b6 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Tue, 4 Mar 2025 16:02:33 +0000
Subject: [PATCH 004/534] Rust: Model more sinks + flows.
---
.../rust/frameworks/genericarray.model.yml | 9 +
.../rustcrypto/rustcrypto.model.yml | 31 ++++
.../HardcodedCryptographicValue.expected | 162 +++++++++++++++++-
.../security/CWE-798/test_cipher.rs | 20 +--
4 files changed, 211 insertions(+), 11 deletions(-)
create mode 100644 rust/ql/lib/codeql/rust/frameworks/genericarray.model.yml
diff --git a/rust/ql/lib/codeql/rust/frameworks/genericarray.model.yml b/rust/ql/lib/codeql/rust/frameworks/genericarray.model.yml
new file mode 100644
index 00000000000..29a72e2666c
--- /dev/null
+++ b/rust/ql/lib/codeql/rust/frameworks/genericarray.model.yml
@@ -0,0 +1,9 @@
+extensions:
+ - addsTo:
+ pack: codeql/rust-all
+ extensible: summaryModel
+ data:
+ - ["repo:https://github.com/fizyk20/generic-array.git:generic-array", "::from_slice", "Argument[0].Reference", "ReturnValue.Reference", "value", "manual"]
+ - ["repo:https://github.com/fizyk20/generic-array.git:generic-array", "::from_mut_slice", "Argument[0].Reference", "ReturnValue.Reference", "value", "manual"]
+ - ["repo:https://github.com/fizyk20/generic-array.git:generic-array", "::try_from_slice", "Argument[0].Reference", "ReturnValue.Field[crate::result::Result::Ok(0)].Reference", "value", "manual"]
+ - ["repo:https://github.com/fizyk20/generic-array.git:generic-array", "::try_from_mut_slice", "Argument[0].Reference", "ReturnValue.Field[crate::result::Result::Ok(0)].Reference", "value", "manual"]
diff --git a/rust/ql/lib/codeql/rust/frameworks/rustcrypto/rustcrypto.model.yml b/rust/ql/lib/codeql/rust/frameworks/rustcrypto/rustcrypto.model.yml
index baf21e9d6cc..5b5b42ca309 100644
--- a/rust/ql/lib/codeql/rust/frameworks/rustcrypto/rustcrypto.model.yml
+++ b/rust/ql/lib/codeql/rust/frameworks/rustcrypto/rustcrypto.model.yml
@@ -8,4 +8,35 @@ extensions:
- ["repo:https://github.com/RustCrypto/traits:digest", "<_ as crate::digest::Digest>::chain_update", "Argument[0]", "hasher-input", "manual"]
- ["repo:https://github.com/RustCrypto/traits:digest", "<_ as crate::digest::Digest>::digest", "Argument[0]", "hasher-input", "manual"]
- ["repo:https://github.com/stainless-steel/md5:md5", "crate::compute", "Argument[0]", "hasher-input", "manual"]
+ - ["repo:https://github.com/RustCrypto/traits:cipher", "::new", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/traits:cipher", "::new_from_slice", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/traits:cipher", "::new", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/traits:cipher", "::new", "Argument[1]", "credentials-iv", "manual"]
+ - ["repo:https://github.com/RustCrypto/traits:cipher", "::new_from_slice", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/traits:cipher", "::new_from_slice", "Argument[1]", "credentials-iv", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new_from_slice", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new_from_slice", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new_from_slice", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new_from_slice", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new_from_slice", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new_from_slice", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new_from_slice", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new_from_slice", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new_from_slice", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/traits:crypto-common", "crate::KeyInit::new", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/traits:crypto-common", "crate::KeyInit::new", "Argument[1]", "credentials-iv", "manual"]
- ["repo:https://github.com/RustCrypto/traits:crypto-common", "crate::KeyInit::new_from_slice", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/traits:crypto-common", "crate::KeyInit::new_from_slice", "Argument[1]", "credentials-iv", "manual"]
+ - ["repo:https://github.com/RustCrypto/traits:crypto-common", "<_ as crate::KeyIvInit>::new", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/traits:crypto-common", "<_ as crate::KeyIvInit>::new", "Argument[1]", "credentials-iv", "manual"]
+ - ["repo:https://github.com/RustCrypto/traits:crypto-common", "<_ as crate::KeyIvInit>::new_from_slices", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/traits:crypto-common", "<_ as crate::KeyIvInit>::new_from_slices", "Argument[1]", "credentials-iv", "manual"]
diff --git a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
index 4e3e67e41e0..f7ab5392e75 100644
--- a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
+++ b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
@@ -1,12 +1,172 @@
#select
+| test_cipher.rs:18:30:18:32 | 0u8 | test_cipher.rs:18:30:18:32 | 0u8 | test_cipher.rs:19:30:19:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:19:30:19:47 | ...::new | key |
+| test_cipher.rs:25:30:25:32 | 0u8 | test_cipher.rs:25:30:25:32 | 0u8 | test_cipher.rs:26:30:26:40 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:26:30:26:40 | ...::new | key |
+| test_cipher.rs:29:30:29:32 | 0u8 | test_cipher.rs:29:30:29:32 | 0u8 | test_cipher.rs:30:30:30:40 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:30:30:30:40 | ...::new | iv |
+| test_cipher.rs:37:28:37:28 | 0 | test_cipher.rs:37:28:37:28 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
+| test_cipher.rs:37:31:37:31 | 0 | test_cipher.rs:37:31:37:31 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
+| test_cipher.rs:37:34:37:34 | 0 | test_cipher.rs:37:34:37:34 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
+| test_cipher.rs:37:37:37:37 | 0 | test_cipher.rs:37:37:37:37 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
+| test_cipher.rs:37:40:37:40 | 0 | test_cipher.rs:37:40:37:40 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
+| test_cipher.rs:37:43:37:43 | 0 | test_cipher.rs:37:43:37:43 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
+| test_cipher.rs:37:46:37:46 | 0 | test_cipher.rs:37:46:37:46 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
+| test_cipher.rs:37:49:37:49 | 0 | test_cipher.rs:37:49:37:49 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
+| test_cipher.rs:37:52:37:52 | 0 | test_cipher.rs:37:52:37:52 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
+| test_cipher.rs:37:55:37:55 | 0 | test_cipher.rs:37:55:37:55 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
+| test_cipher.rs:37:58:37:58 | 0 | test_cipher.rs:37:58:37:58 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
+| test_cipher.rs:37:61:37:61 | 0 | test_cipher.rs:37:61:37:61 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
+| test_cipher.rs:37:64:37:64 | 0 | test_cipher.rs:37:64:37:64 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
+| test_cipher.rs:37:67:37:67 | 0 | test_cipher.rs:37:67:37:67 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
+| test_cipher.rs:37:70:37:70 | 0 | test_cipher.rs:37:70:37:70 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
+| test_cipher.rs:37:73:37:73 | 0 | test_cipher.rs:37:73:37:73 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
+| test_cipher.rs:41:30:41:30 | 0 | test_cipher.rs:41:30:41:30 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
+| test_cipher.rs:41:33:41:33 | 0 | test_cipher.rs:41:33:41:33 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
+| test_cipher.rs:41:36:41:36 | 0 | test_cipher.rs:41:36:41:36 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
+| test_cipher.rs:41:39:41:39 | 0 | test_cipher.rs:41:39:41:39 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
+| test_cipher.rs:41:42:41:42 | 0 | test_cipher.rs:41:42:41:42 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
+| test_cipher.rs:41:45:41:45 | 0 | test_cipher.rs:41:45:41:45 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
+| test_cipher.rs:41:48:41:48 | 0 | test_cipher.rs:41:48:41:48 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
+| test_cipher.rs:41:51:41:51 | 0 | test_cipher.rs:41:51:41:51 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
+| test_cipher.rs:41:54:41:54 | 0 | test_cipher.rs:41:54:41:54 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
+| test_cipher.rs:41:57:41:57 | 0 | test_cipher.rs:41:57:41:57 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
+| test_cipher.rs:41:60:41:60 | 0 | test_cipher.rs:41:60:41:60 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
+| test_cipher.rs:41:63:41:63 | 0 | test_cipher.rs:41:63:41:63 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
+| test_cipher.rs:41:66:41:66 | 0 | test_cipher.rs:41:66:41:66 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
+| test_cipher.rs:41:69:41:69 | 0 | test_cipher.rs:41:69:41:69 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
+| test_cipher.rs:41:72:41:72 | 0 | test_cipher.rs:41:72:41:72 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
+| test_cipher.rs:41:75:41:75 | 0 | test_cipher.rs:41:75:41:75 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
| test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:74:23:74:44 | ...::new_from_slice | This hard-coded value is used as $@. | test_cipher.rs:74:23:74:44 | ...::new_from_slice | key |
edges
+| test_cipher.rs:18:9:18:14 | const1 [&ref, element] | test_cipher.rs:19:73:19:78 | const1 [&ref, element] | provenance | |
+| test_cipher.rs:18:28:18:36 | &... [&ref, element] | test_cipher.rs:18:9:18:14 | const1 [&ref, element] | provenance | |
+| test_cipher.rs:18:29:18:36 | [0u8; 16] [element] | test_cipher.rs:18:28:18:36 | &... [&ref, element] | provenance | |
+| test_cipher.rs:18:30:18:32 | 0u8 | test_cipher.rs:18:29:18:36 | [0u8; 16] [element] | provenance | |
+| test_cipher.rs:19:49:19:79 | ...::from_slice(...) [&ref, element] | test_cipher.rs:19:30:19:47 | ...::new | provenance | MaD:58 Sink:MaD:58 Sink:MaD:58 |
+| test_cipher.rs:19:73:19:78 | const1 [&ref, element] | test_cipher.rs:19:49:19:79 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
+| test_cipher.rs:25:9:25:14 | const4 [&ref, element] | test_cipher.rs:26:66:26:71 | const4 [&ref, element] | provenance | |
+| test_cipher.rs:25:28:25:36 | &... [&ref, element] | test_cipher.rs:25:9:25:14 | const4 [&ref, element] | provenance | |
+| test_cipher.rs:25:29:25:36 | [0u8; 16] [element] | test_cipher.rs:25:28:25:36 | &... [&ref, element] | provenance | |
+| test_cipher.rs:25:30:25:32 | 0u8 | test_cipher.rs:25:29:25:36 | [0u8; 16] [element] | provenance | |
+| test_cipher.rs:26:42:26:72 | ...::from_slice(...) [&ref, element] | test_cipher.rs:26:30:26:40 | ...::new | provenance | MaD:82 Sink:MaD:82 Sink:MaD:82 |
+| test_cipher.rs:26:66:26:71 | const4 [&ref, element] | test_cipher.rs:26:42:26:72 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
+| test_cipher.rs:29:9:29:14 | const5 [&ref, element] | test_cipher.rs:30:95:30:100 | const5 [&ref, element] | provenance | |
+| test_cipher.rs:29:28:29:36 | &... [&ref, element] | test_cipher.rs:29:9:29:14 | const5 [&ref, element] | provenance | |
+| test_cipher.rs:29:29:29:36 | [0u8; 16] [element] | test_cipher.rs:29:28:29:36 | &... [&ref, element] | provenance | |
+| test_cipher.rs:29:30:29:32 | 0u8 | test_cipher.rs:29:29:29:36 | [0u8; 16] [element] | provenance | |
+| test_cipher.rs:30:72:30:101 | ...::from_slice(...) [&ref, element] | test_cipher.rs:30:30:30:40 | ...::new | provenance | MaD:83 Sink:MaD:83 Sink:MaD:83 |
+| test_cipher.rs:30:95:30:100 | const5 [&ref, element] | test_cipher.rs:30:72:30:101 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
+| test_cipher.rs:37:9:37:14 | const7 [element] | test_cipher.rs:38:74:38:79 | const7 [element] | provenance | |
+| test_cipher.rs:37:27:37:74 | [...] [element] | test_cipher.rs:37:9:37:14 | const7 [element] | provenance | |
+| test_cipher.rs:37:28:37:28 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
+| test_cipher.rs:37:31:37:31 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
+| test_cipher.rs:37:34:37:34 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
+| test_cipher.rs:37:37:37:37 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
+| test_cipher.rs:37:40:37:40 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
+| test_cipher.rs:37:43:37:43 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
+| test_cipher.rs:37:46:37:46 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
+| test_cipher.rs:37:49:37:49 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
+| test_cipher.rs:37:52:37:52 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
+| test_cipher.rs:37:55:37:55 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
+| test_cipher.rs:37:58:37:58 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
+| test_cipher.rs:37:61:37:61 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
+| test_cipher.rs:37:64:37:64 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
+| test_cipher.rs:37:67:37:67 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
+| test_cipher.rs:37:70:37:70 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
+| test_cipher.rs:37:73:37:73 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
+| test_cipher.rs:38:49:38:80 | ...::from_slice(...) [&ref, element] | test_cipher.rs:38:30:38:47 | ...::new | provenance | MaD:58 Sink:MaD:58 Sink:MaD:58 |
+| test_cipher.rs:38:73:38:79 | &const7 [&ref, element] | test_cipher.rs:38:49:38:80 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
+| test_cipher.rs:38:74:38:79 | const7 [element] | test_cipher.rs:38:73:38:79 | &const7 [&ref, element] | provenance | |
+| test_cipher.rs:41:9:41:14 | const8 [&ref, element] | test_cipher.rs:42:73:42:78 | const8 [&ref, element] | provenance | |
+| test_cipher.rs:41:28:41:76 | &... [&ref, element] | test_cipher.rs:41:9:41:14 | const8 [&ref, element] | provenance | |
+| test_cipher.rs:41:29:41:76 | [...] [element] | test_cipher.rs:41:28:41:76 | &... [&ref, element] | provenance | |
+| test_cipher.rs:41:30:41:30 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
+| test_cipher.rs:41:33:41:33 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
+| test_cipher.rs:41:36:41:36 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
+| test_cipher.rs:41:39:41:39 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
+| test_cipher.rs:41:42:41:42 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
+| test_cipher.rs:41:45:41:45 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
+| test_cipher.rs:41:48:41:48 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
+| test_cipher.rs:41:51:41:51 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
+| test_cipher.rs:41:54:41:54 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
+| test_cipher.rs:41:57:41:57 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
+| test_cipher.rs:41:60:41:60 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
+| test_cipher.rs:41:63:41:63 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
+| test_cipher.rs:41:66:41:66 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
+| test_cipher.rs:41:69:41:69 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
+| test_cipher.rs:41:72:41:72 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
+| test_cipher.rs:41:75:41:75 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
+| test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref, element] | test_cipher.rs:42:30:42:47 | ...::new | provenance | MaD:58 Sink:MaD:58 Sink:MaD:58 |
+| test_cipher.rs:42:73:42:78 | const8 [&ref, element] | test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
| test_cipher.rs:73:9:73:14 | const2 [&ref, element] | test_cipher.rs:74:46:74:51 | const2 [&ref, element] | provenance | |
| test_cipher.rs:73:18:73:26 | &... [&ref, element] | test_cipher.rs:73:9:73:14 | const2 [&ref, element] | provenance | |
| test_cipher.rs:73:19:73:26 | [0u8; 32] [element] | test_cipher.rs:73:18:73:26 | &... [&ref, element] | provenance | |
| test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:73:19:73:26 | [0u8; 32] [element] | provenance | |
-| test_cipher.rs:74:46:74:51 | const2 [&ref, element] | test_cipher.rs:74:23:74:44 | ...::new_from_slice | provenance | MaD:54 Sink:MaD:54 Sink:MaD:54 |
+| test_cipher.rs:74:46:74:51 | const2 [&ref, element] | test_cipher.rs:74:23:74:44 | ...::new_from_slice | provenance | MaD:84 Sink:MaD:84 Sink:MaD:84 |
nodes
+| test_cipher.rs:18:9:18:14 | const1 [&ref, element] | semmle.label | const1 [&ref, element] |
+| test_cipher.rs:18:28:18:36 | &... [&ref, element] | semmle.label | &... [&ref, element] |
+| test_cipher.rs:18:29:18:36 | [0u8; 16] [element] | semmle.label | [0u8; 16] [element] |
+| test_cipher.rs:18:30:18:32 | 0u8 | semmle.label | 0u8 |
+| test_cipher.rs:19:30:19:47 | ...::new | semmle.label | ...::new |
+| test_cipher.rs:19:49:19:79 | ...::from_slice(...) [&ref, element] | semmle.label | ...::from_slice(...) [&ref, element] |
+| test_cipher.rs:19:73:19:78 | const1 [&ref, element] | semmle.label | const1 [&ref, element] |
+| test_cipher.rs:25:9:25:14 | const4 [&ref, element] | semmle.label | const4 [&ref, element] |
+| test_cipher.rs:25:28:25:36 | &... [&ref, element] | semmle.label | &... [&ref, element] |
+| test_cipher.rs:25:29:25:36 | [0u8; 16] [element] | semmle.label | [0u8; 16] [element] |
+| test_cipher.rs:25:30:25:32 | 0u8 | semmle.label | 0u8 |
+| test_cipher.rs:26:30:26:40 | ...::new | semmle.label | ...::new |
+| test_cipher.rs:26:42:26:72 | ...::from_slice(...) [&ref, element] | semmle.label | ...::from_slice(...) [&ref, element] |
+| test_cipher.rs:26:66:26:71 | const4 [&ref, element] | semmle.label | const4 [&ref, element] |
+| test_cipher.rs:29:9:29:14 | const5 [&ref, element] | semmle.label | const5 [&ref, element] |
+| test_cipher.rs:29:28:29:36 | &... [&ref, element] | semmle.label | &... [&ref, element] |
+| test_cipher.rs:29:29:29:36 | [0u8; 16] [element] | semmle.label | [0u8; 16] [element] |
+| test_cipher.rs:29:30:29:32 | 0u8 | semmle.label | 0u8 |
+| test_cipher.rs:30:30:30:40 | ...::new | semmle.label | ...::new |
+| test_cipher.rs:30:72:30:101 | ...::from_slice(...) [&ref, element] | semmle.label | ...::from_slice(...) [&ref, element] |
+| test_cipher.rs:30:95:30:100 | const5 [&ref, element] | semmle.label | const5 [&ref, element] |
+| test_cipher.rs:37:9:37:14 | const7 [element] | semmle.label | const7 [element] |
+| test_cipher.rs:37:27:37:74 | [...] [element] | semmle.label | [...] [element] |
+| test_cipher.rs:37:28:37:28 | 0 | semmle.label | 0 |
+| test_cipher.rs:37:31:37:31 | 0 | semmle.label | 0 |
+| test_cipher.rs:37:34:37:34 | 0 | semmle.label | 0 |
+| test_cipher.rs:37:37:37:37 | 0 | semmle.label | 0 |
+| test_cipher.rs:37:40:37:40 | 0 | semmle.label | 0 |
+| test_cipher.rs:37:43:37:43 | 0 | semmle.label | 0 |
+| test_cipher.rs:37:46:37:46 | 0 | semmle.label | 0 |
+| test_cipher.rs:37:49:37:49 | 0 | semmle.label | 0 |
+| test_cipher.rs:37:52:37:52 | 0 | semmle.label | 0 |
+| test_cipher.rs:37:55:37:55 | 0 | semmle.label | 0 |
+| test_cipher.rs:37:58:37:58 | 0 | semmle.label | 0 |
+| test_cipher.rs:37:61:37:61 | 0 | semmle.label | 0 |
+| test_cipher.rs:37:64:37:64 | 0 | semmle.label | 0 |
+| test_cipher.rs:37:67:37:67 | 0 | semmle.label | 0 |
+| test_cipher.rs:37:70:37:70 | 0 | semmle.label | 0 |
+| test_cipher.rs:37:73:37:73 | 0 | semmle.label | 0 |
+| test_cipher.rs:38:30:38:47 | ...::new | semmle.label | ...::new |
+| test_cipher.rs:38:49:38:80 | ...::from_slice(...) [&ref, element] | semmle.label | ...::from_slice(...) [&ref, element] |
+| test_cipher.rs:38:73:38:79 | &const7 [&ref, element] | semmle.label | &const7 [&ref, element] |
+| test_cipher.rs:38:74:38:79 | const7 [element] | semmle.label | const7 [element] |
+| test_cipher.rs:41:9:41:14 | const8 [&ref, element] | semmle.label | const8 [&ref, element] |
+| test_cipher.rs:41:28:41:76 | &... [&ref, element] | semmle.label | &... [&ref, element] |
+| test_cipher.rs:41:29:41:76 | [...] [element] | semmle.label | [...] [element] |
+| test_cipher.rs:41:30:41:30 | 0 | semmle.label | 0 |
+| test_cipher.rs:41:33:41:33 | 0 | semmle.label | 0 |
+| test_cipher.rs:41:36:41:36 | 0 | semmle.label | 0 |
+| test_cipher.rs:41:39:41:39 | 0 | semmle.label | 0 |
+| test_cipher.rs:41:42:41:42 | 0 | semmle.label | 0 |
+| test_cipher.rs:41:45:41:45 | 0 | semmle.label | 0 |
+| test_cipher.rs:41:48:41:48 | 0 | semmle.label | 0 |
+| test_cipher.rs:41:51:41:51 | 0 | semmle.label | 0 |
+| test_cipher.rs:41:54:41:54 | 0 | semmle.label | 0 |
+| test_cipher.rs:41:57:41:57 | 0 | semmle.label | 0 |
+| test_cipher.rs:41:60:41:60 | 0 | semmle.label | 0 |
+| test_cipher.rs:41:63:41:63 | 0 | semmle.label | 0 |
+| test_cipher.rs:41:66:41:66 | 0 | semmle.label | 0 |
+| test_cipher.rs:41:69:41:69 | 0 | semmle.label | 0 |
+| test_cipher.rs:41:72:41:72 | 0 | semmle.label | 0 |
+| test_cipher.rs:41:75:41:75 | 0 | semmle.label | 0 |
+| test_cipher.rs:42:30:42:47 | ...::new | semmle.label | ...::new |
+| test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref, element] | semmle.label | ...::from_slice(...) [&ref, element] |
+| test_cipher.rs:42:73:42:78 | const8 [&ref, element] | semmle.label | const8 [&ref, element] |
| test_cipher.rs:73:9:73:14 | const2 [&ref, element] | semmle.label | const2 [&ref, element] |
| test_cipher.rs:73:18:73:26 | &... [&ref, element] | semmle.label | &... [&ref, element] |
| test_cipher.rs:73:19:73:26 | [0u8; 32] [element] | semmle.label | [0u8; 32] [element] |
diff --git a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
index cfd07d688a1..cfa20ab13c2 100644
--- a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
+++ b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
@@ -15,31 +15,31 @@ fn test_stream_cipher_rabbit(
let mut rabbit_cipher1 = RabbitKeyOnly::new(rabbit::Key::from_slice(key));
rabbit_cipher1.apply_keystream(&mut data);
- let const1: &[u8;16] = &[0u8;16]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
- let mut rabbit_cipher2 = RabbitKeyOnly::new(rabbit::Key::from_slice(const1));
+ let const1: &[u8;16] = &[0u8;16]; // $ Alert[rust/hardcoded-crytographic-value]
+ let mut rabbit_cipher2 = RabbitKeyOnly::new(rabbit::Key::from_slice(const1)); // $ Sink
rabbit_cipher2.apply_keystream(&mut data);
let mut rabbit_cipher3 = Rabbit::new(rabbit::Key::from_slice(key), rabbit::Iv::from_slice(iv));
rabbit_cipher3.apply_keystream(&mut data);
- let const4: &[u8;16] = &[0u8;16]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
- let mut rabbit_cipher4 = Rabbit::new(rabbit::Key::from_slice(const4), rabbit::Iv::from_slice(iv));
+ let const4: &[u8;16] = &[0u8;16]; // $ Alert[rust/hardcoded-crytographic-value]
+ let mut rabbit_cipher4 = Rabbit::new(rabbit::Key::from_slice(const4), rabbit::Iv::from_slice(iv)); // $ Sink
rabbit_cipher4.apply_keystream(&mut data);
- let const5: &[u8;16] = &[0u8;16]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
- let mut rabbit_cipher5 = Rabbit::new(rabbit::Key::from_slice(key), rabbit::Iv::from_slice(const5));
+ let const5: &[u8;16] = &[0u8;16]; // $ Alert[rust/hardcoded-crytographic-value]
+ let mut rabbit_cipher5 = Rabbit::new(rabbit::Key::from_slice(key), rabbit::Iv::from_slice(const5)); // $ Sink
rabbit_cipher5.apply_keystream(&mut data);
// various expressions of constant arrays
let const6: &[u8;16] = &[0u8;16]; // (unused, so good)
- let const7: [u8;16] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
- let mut rabbit_cipher7 = RabbitKeyOnly::new(rabbit::Key::from_slice(&const7));
+ let const7: [u8;16] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // $ Alert[rust/hardcoded-crytographic-value]
+ let mut rabbit_cipher7 = RabbitKeyOnly::new(rabbit::Key::from_slice(&const7)); // $ Sink
rabbit_cipher7.apply_keystream(&mut data);
- let const8: &[u8;16] = &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
- let mut rabbit_cipher8 = RabbitKeyOnly::new(rabbit::Key::from_slice(const8));
+ let const8: &[u8;16] = &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // $ Alert[rust/hardcoded-crytographic-value]
+ let mut rabbit_cipher8 = RabbitKeyOnly::new(rabbit::Key::from_slice(const8)); // $ Sink
rabbit_cipher8.apply_keystream(&mut data);
let const9: [u16;8] = [0, 0, 0, 0, 0, 0, 0, 0]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
From aacbfc0fd88af543a665bc7d2fa27b884091e98c Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Wed, 5 Mar 2025 10:38:04 +0000
Subject: [PATCH 005/534] Rust: Improve alert messages.
---
.../HardcodedCryptographicValueExtensions.qll | 34 ++++++---
.../CWE-798/HardcodedCryptographicValue.ql | 2 +-
.../HardcodedCryptographicValue.expected | 72 +++++++++----------
3 files changed, 62 insertions(+), 46 deletions(-)
diff --git a/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll b/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
index 006f4fd8139..246d138f91b 100644
--- a/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
+++ b/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
@@ -8,6 +8,26 @@ private import codeql.rust.dataflow.DataFlow
private import codeql.rust.dataflow.internal.DataFlowImpl
private import codeql.rust.security.SensitiveData
+/**
+ * A kind of cryptographic value.
+ */
+class CryptographicValueKind extends string {
+ CryptographicValueKind() { this = ["password", "key", "iv", "salt"] }
+
+ /**
+ * Gets a description of this value kind for user-facing messages.
+ */
+ string getDescription() {
+ this = "password" and result = "a password"
+ or
+ this = "key" and result = "a key"
+ or
+ this = "iv" and result = "an initialization vector"
+ or
+ this = "salt" and result = "a salt"
+ }
+}
+
/**
* Provides default sources, sinks and barriers for detecting hardcoded cryptographic
* value vulnerabilities, as well as extension points for adding your own.
@@ -23,10 +43,9 @@ module HardcodedCryptographicValue {
*/
abstract class Sink extends DataFlow::Node {
/**
- * Gets the kind of credential this sink is interpreted as,
- * for example "password", "key", "iv", "salt".
+ * Gets the kind of credential this sink is interpreted as.
*/
- abstract string getKind();
+ abstract CryptographicValueKind getKind();
}
/**
@@ -45,13 +64,10 @@ module HardcodedCryptographicValue {
* A sink for hardcoded cryptographic value from model data.
*/
private class ModelsAsDataSinks extends Sink {
- string kind;
+ CryptographicValueKind kind;
- ModelsAsDataSinks() {
- kind = ["password", "key", "iv", "salt"] and
- sinkNode(this, "credentials-" + kind)
- }
+ ModelsAsDataSinks() { sinkNode(this, "credentials-" + kind) }
- override string getKind() { result = kind }
+ override CryptographicValueKind getKind() { result = kind }
}
}
diff --git a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
index 2ec8ea8c257..716604ee484 100644
--- a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
+++ b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
@@ -47,4 +47,4 @@ from
HardcodedCryptographicValueFlow::PathNode source, HardcodedCryptographicValueFlow::PathNode sink
where HardcodedCryptographicValueFlow::flowPath(source, sink)
select source.getNode(), source, sink, "This hard-coded value is used as $@.", sink,
- sink.getNode().(HardcodedCryptographicValueConfig::Sink).getKind()
+ sink.getNode().(HardcodedCryptographicValueConfig::Sink).getKind().getDescription()
diff --git a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
index f7ab5392e75..9a52e7e2f5d 100644
--- a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
+++ b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
@@ -1,40 +1,40 @@
#select
-| test_cipher.rs:18:30:18:32 | 0u8 | test_cipher.rs:18:30:18:32 | 0u8 | test_cipher.rs:19:30:19:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:19:30:19:47 | ...::new | key |
-| test_cipher.rs:25:30:25:32 | 0u8 | test_cipher.rs:25:30:25:32 | 0u8 | test_cipher.rs:26:30:26:40 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:26:30:26:40 | ...::new | key |
-| test_cipher.rs:29:30:29:32 | 0u8 | test_cipher.rs:29:30:29:32 | 0u8 | test_cipher.rs:30:30:30:40 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:30:30:30:40 | ...::new | iv |
-| test_cipher.rs:37:28:37:28 | 0 | test_cipher.rs:37:28:37:28 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
-| test_cipher.rs:37:31:37:31 | 0 | test_cipher.rs:37:31:37:31 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
-| test_cipher.rs:37:34:37:34 | 0 | test_cipher.rs:37:34:37:34 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
-| test_cipher.rs:37:37:37:37 | 0 | test_cipher.rs:37:37:37:37 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
-| test_cipher.rs:37:40:37:40 | 0 | test_cipher.rs:37:40:37:40 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
-| test_cipher.rs:37:43:37:43 | 0 | test_cipher.rs:37:43:37:43 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
-| test_cipher.rs:37:46:37:46 | 0 | test_cipher.rs:37:46:37:46 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
-| test_cipher.rs:37:49:37:49 | 0 | test_cipher.rs:37:49:37:49 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
-| test_cipher.rs:37:52:37:52 | 0 | test_cipher.rs:37:52:37:52 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
-| test_cipher.rs:37:55:37:55 | 0 | test_cipher.rs:37:55:37:55 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
-| test_cipher.rs:37:58:37:58 | 0 | test_cipher.rs:37:58:37:58 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
-| test_cipher.rs:37:61:37:61 | 0 | test_cipher.rs:37:61:37:61 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
-| test_cipher.rs:37:64:37:64 | 0 | test_cipher.rs:37:64:37:64 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
-| test_cipher.rs:37:67:37:67 | 0 | test_cipher.rs:37:67:37:67 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
-| test_cipher.rs:37:70:37:70 | 0 | test_cipher.rs:37:70:37:70 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
-| test_cipher.rs:37:73:37:73 | 0 | test_cipher.rs:37:73:37:73 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | key |
-| test_cipher.rs:41:30:41:30 | 0 | test_cipher.rs:41:30:41:30 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
-| test_cipher.rs:41:33:41:33 | 0 | test_cipher.rs:41:33:41:33 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
-| test_cipher.rs:41:36:41:36 | 0 | test_cipher.rs:41:36:41:36 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
-| test_cipher.rs:41:39:41:39 | 0 | test_cipher.rs:41:39:41:39 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
-| test_cipher.rs:41:42:41:42 | 0 | test_cipher.rs:41:42:41:42 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
-| test_cipher.rs:41:45:41:45 | 0 | test_cipher.rs:41:45:41:45 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
-| test_cipher.rs:41:48:41:48 | 0 | test_cipher.rs:41:48:41:48 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
-| test_cipher.rs:41:51:41:51 | 0 | test_cipher.rs:41:51:41:51 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
-| test_cipher.rs:41:54:41:54 | 0 | test_cipher.rs:41:54:41:54 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
-| test_cipher.rs:41:57:41:57 | 0 | test_cipher.rs:41:57:41:57 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
-| test_cipher.rs:41:60:41:60 | 0 | test_cipher.rs:41:60:41:60 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
-| test_cipher.rs:41:63:41:63 | 0 | test_cipher.rs:41:63:41:63 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
-| test_cipher.rs:41:66:41:66 | 0 | test_cipher.rs:41:66:41:66 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
-| test_cipher.rs:41:69:41:69 | 0 | test_cipher.rs:41:69:41:69 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
-| test_cipher.rs:41:72:41:72 | 0 | test_cipher.rs:41:72:41:72 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
-| test_cipher.rs:41:75:41:75 | 0 | test_cipher.rs:41:75:41:75 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | key |
-| test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:74:23:74:44 | ...::new_from_slice | This hard-coded value is used as $@. | test_cipher.rs:74:23:74:44 | ...::new_from_slice | key |
+| test_cipher.rs:18:30:18:32 | 0u8 | test_cipher.rs:18:30:18:32 | 0u8 | test_cipher.rs:19:30:19:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:19:30:19:47 | ...::new | a key |
+| test_cipher.rs:25:30:25:32 | 0u8 | test_cipher.rs:25:30:25:32 | 0u8 | test_cipher.rs:26:30:26:40 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:26:30:26:40 | ...::new | a key |
+| test_cipher.rs:29:30:29:32 | 0u8 | test_cipher.rs:29:30:29:32 | 0u8 | test_cipher.rs:30:30:30:40 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:30:30:30:40 | ...::new | an initialization vector |
+| test_cipher.rs:37:28:37:28 | 0 | test_cipher.rs:37:28:37:28 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
+| test_cipher.rs:37:31:37:31 | 0 | test_cipher.rs:37:31:37:31 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
+| test_cipher.rs:37:34:37:34 | 0 | test_cipher.rs:37:34:37:34 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
+| test_cipher.rs:37:37:37:37 | 0 | test_cipher.rs:37:37:37:37 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
+| test_cipher.rs:37:40:37:40 | 0 | test_cipher.rs:37:40:37:40 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
+| test_cipher.rs:37:43:37:43 | 0 | test_cipher.rs:37:43:37:43 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
+| test_cipher.rs:37:46:37:46 | 0 | test_cipher.rs:37:46:37:46 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
+| test_cipher.rs:37:49:37:49 | 0 | test_cipher.rs:37:49:37:49 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
+| test_cipher.rs:37:52:37:52 | 0 | test_cipher.rs:37:52:37:52 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
+| test_cipher.rs:37:55:37:55 | 0 | test_cipher.rs:37:55:37:55 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
+| test_cipher.rs:37:58:37:58 | 0 | test_cipher.rs:37:58:37:58 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
+| test_cipher.rs:37:61:37:61 | 0 | test_cipher.rs:37:61:37:61 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
+| test_cipher.rs:37:64:37:64 | 0 | test_cipher.rs:37:64:37:64 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
+| test_cipher.rs:37:67:37:67 | 0 | test_cipher.rs:37:67:37:67 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
+| test_cipher.rs:37:70:37:70 | 0 | test_cipher.rs:37:70:37:70 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
+| test_cipher.rs:37:73:37:73 | 0 | test_cipher.rs:37:73:37:73 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
+| test_cipher.rs:41:30:41:30 | 0 | test_cipher.rs:41:30:41:30 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
+| test_cipher.rs:41:33:41:33 | 0 | test_cipher.rs:41:33:41:33 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
+| test_cipher.rs:41:36:41:36 | 0 | test_cipher.rs:41:36:41:36 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
+| test_cipher.rs:41:39:41:39 | 0 | test_cipher.rs:41:39:41:39 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
+| test_cipher.rs:41:42:41:42 | 0 | test_cipher.rs:41:42:41:42 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
+| test_cipher.rs:41:45:41:45 | 0 | test_cipher.rs:41:45:41:45 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
+| test_cipher.rs:41:48:41:48 | 0 | test_cipher.rs:41:48:41:48 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
+| test_cipher.rs:41:51:41:51 | 0 | test_cipher.rs:41:51:41:51 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
+| test_cipher.rs:41:54:41:54 | 0 | test_cipher.rs:41:54:41:54 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
+| test_cipher.rs:41:57:41:57 | 0 | test_cipher.rs:41:57:41:57 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
+| test_cipher.rs:41:60:41:60 | 0 | test_cipher.rs:41:60:41:60 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
+| test_cipher.rs:41:63:41:63 | 0 | test_cipher.rs:41:63:41:63 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
+| test_cipher.rs:41:66:41:66 | 0 | test_cipher.rs:41:66:41:66 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
+| test_cipher.rs:41:69:41:69 | 0 | test_cipher.rs:41:69:41:69 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
+| test_cipher.rs:41:72:41:72 | 0 | test_cipher.rs:41:72:41:72 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
+| test_cipher.rs:41:75:41:75 | 0 | test_cipher.rs:41:75:41:75 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
+| test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:74:23:74:44 | ...::new_from_slice | This hard-coded value is used as $@. | test_cipher.rs:74:23:74:44 | ...::new_from_slice | a key |
edges
| test_cipher.rs:18:9:18:14 | const1 [&ref, element] | test_cipher.rs:19:73:19:78 | const1 [&ref, element] | provenance | |
| test_cipher.rs:18:28:18:36 | &... [&ref, element] | test_cipher.rs:18:9:18:14 | const1 [&ref, element] | provenance | |
From 055baf2769bda0d87bdffc853095038cbe4807c8 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Thu, 6 Mar 2025 15:46:51 +0000
Subject: [PATCH 006/534] Rust: Improve results on arrays (less duplication).
---
.../HardcodedCryptographicValueExtensions.qll | 12 ++
.../CWE-798/HardcodedCryptographicValue.ql | 7 +
.../HardcodedCryptographicValue.expected | 138 +++---------------
3 files changed, 41 insertions(+), 116 deletions(-)
diff --git a/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll b/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
index 246d138f91b..f7f26032b51 100644
--- a/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
+++ b/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
@@ -60,6 +60,18 @@ module HardcodedCryptographicValue {
LiteralSource() { this.asExpr().getExpr() instanceof LiteralExpr }
}
+ /**
+ * An array initialized from a list of literals, considered as a single flow source. For example:
+ * ```
+ * `[0, 0, 0, 0]`
+ * ```
+ */
+ private class ArrayListSource extends Source {
+ ArrayListSource() {
+ this.asExpr().getExpr().(ArrayListExpr).getExpr(_) instanceof LiteralExpr
+ }
+ }
+
/**
* A sink for hardcoded cryptographic value from model data.
*/
diff --git a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
index 716604ee484..441c22f679a 100644
--- a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
+++ b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
@@ -32,6 +32,13 @@ module HardcodedCryptographicValueConfig implements DataFlow::ConfigSig {
predicate isBarrier(DataFlow::Node barrier) { barrier instanceof Barrier }
+ predicate isBarrierIn(DataFlow::Node node) {
+ // make sources barriers so that we only report the closest instance
+ // (this combined with sources for `ArrayListExpr` means we only get one source in
+ // case like `[0, 0, 0, 0]`)
+ isSource(node)
+ }
+
predicate allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c) {
// flow out from reference content at sinks.
isSink(node) and
diff --git a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
index 9a52e7e2f5d..2ed68852eb5 100644
--- a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
+++ b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
@@ -2,38 +2,8 @@
| test_cipher.rs:18:30:18:32 | 0u8 | test_cipher.rs:18:30:18:32 | 0u8 | test_cipher.rs:19:30:19:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:19:30:19:47 | ...::new | a key |
| test_cipher.rs:25:30:25:32 | 0u8 | test_cipher.rs:25:30:25:32 | 0u8 | test_cipher.rs:26:30:26:40 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:26:30:26:40 | ...::new | a key |
| test_cipher.rs:29:30:29:32 | 0u8 | test_cipher.rs:29:30:29:32 | 0u8 | test_cipher.rs:30:30:30:40 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:30:30:30:40 | ...::new | an initialization vector |
-| test_cipher.rs:37:28:37:28 | 0 | test_cipher.rs:37:28:37:28 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
-| test_cipher.rs:37:31:37:31 | 0 | test_cipher.rs:37:31:37:31 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
-| test_cipher.rs:37:34:37:34 | 0 | test_cipher.rs:37:34:37:34 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
-| test_cipher.rs:37:37:37:37 | 0 | test_cipher.rs:37:37:37:37 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
-| test_cipher.rs:37:40:37:40 | 0 | test_cipher.rs:37:40:37:40 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
-| test_cipher.rs:37:43:37:43 | 0 | test_cipher.rs:37:43:37:43 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
-| test_cipher.rs:37:46:37:46 | 0 | test_cipher.rs:37:46:37:46 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
-| test_cipher.rs:37:49:37:49 | 0 | test_cipher.rs:37:49:37:49 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
-| test_cipher.rs:37:52:37:52 | 0 | test_cipher.rs:37:52:37:52 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
-| test_cipher.rs:37:55:37:55 | 0 | test_cipher.rs:37:55:37:55 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
-| test_cipher.rs:37:58:37:58 | 0 | test_cipher.rs:37:58:37:58 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
-| test_cipher.rs:37:61:37:61 | 0 | test_cipher.rs:37:61:37:61 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
-| test_cipher.rs:37:64:37:64 | 0 | test_cipher.rs:37:64:37:64 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
-| test_cipher.rs:37:67:37:67 | 0 | test_cipher.rs:37:67:37:67 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
-| test_cipher.rs:37:70:37:70 | 0 | test_cipher.rs:37:70:37:70 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
-| test_cipher.rs:37:73:37:73 | 0 | test_cipher.rs:37:73:37:73 | 0 | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
-| test_cipher.rs:41:30:41:30 | 0 | test_cipher.rs:41:30:41:30 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
-| test_cipher.rs:41:33:41:33 | 0 | test_cipher.rs:41:33:41:33 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
-| test_cipher.rs:41:36:41:36 | 0 | test_cipher.rs:41:36:41:36 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
-| test_cipher.rs:41:39:41:39 | 0 | test_cipher.rs:41:39:41:39 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
-| test_cipher.rs:41:42:41:42 | 0 | test_cipher.rs:41:42:41:42 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
-| test_cipher.rs:41:45:41:45 | 0 | test_cipher.rs:41:45:41:45 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
-| test_cipher.rs:41:48:41:48 | 0 | test_cipher.rs:41:48:41:48 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
-| test_cipher.rs:41:51:41:51 | 0 | test_cipher.rs:41:51:41:51 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
-| test_cipher.rs:41:54:41:54 | 0 | test_cipher.rs:41:54:41:54 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
-| test_cipher.rs:41:57:41:57 | 0 | test_cipher.rs:41:57:41:57 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
-| test_cipher.rs:41:60:41:60 | 0 | test_cipher.rs:41:60:41:60 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
-| test_cipher.rs:41:63:41:63 | 0 | test_cipher.rs:41:63:41:63 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
-| test_cipher.rs:41:66:41:66 | 0 | test_cipher.rs:41:66:41:66 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
-| test_cipher.rs:41:69:41:69 | 0 | test_cipher.rs:41:69:41:69 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
-| test_cipher.rs:41:72:41:72 | 0 | test_cipher.rs:41:72:41:72 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
-| test_cipher.rs:41:75:41:75 | 0 | test_cipher.rs:41:75:41:75 | 0 | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
+| test_cipher.rs:37:27:37:74 | [...] | test_cipher.rs:37:27:37:74 | [...] | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
+| test_cipher.rs:41:29:41:76 | [...] | test_cipher.rs:41:29:41:76 | [...] | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
| test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:74:23:74:44 | ...::new_from_slice | This hard-coded value is used as $@. | test_cipher.rs:74:23:74:44 | ...::new_from_slice | a key |
edges
| test_cipher.rs:18:9:18:14 | const1 [&ref, element] | test_cipher.rs:19:73:19:78 | const1 [&ref, element] | provenance | |
@@ -54,48 +24,16 @@ edges
| test_cipher.rs:29:30:29:32 | 0u8 | test_cipher.rs:29:29:29:36 | [0u8; 16] [element] | provenance | |
| test_cipher.rs:30:72:30:101 | ...::from_slice(...) [&ref, element] | test_cipher.rs:30:30:30:40 | ...::new | provenance | MaD:83 Sink:MaD:83 Sink:MaD:83 |
| test_cipher.rs:30:95:30:100 | const5 [&ref, element] | test_cipher.rs:30:72:30:101 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
-| test_cipher.rs:37:9:37:14 | const7 [element] | test_cipher.rs:38:74:38:79 | const7 [element] | provenance | |
-| test_cipher.rs:37:27:37:74 | [...] [element] | test_cipher.rs:37:9:37:14 | const7 [element] | provenance | |
-| test_cipher.rs:37:28:37:28 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
-| test_cipher.rs:37:31:37:31 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
-| test_cipher.rs:37:34:37:34 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
-| test_cipher.rs:37:37:37:37 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
-| test_cipher.rs:37:40:37:40 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
-| test_cipher.rs:37:43:37:43 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
-| test_cipher.rs:37:46:37:46 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
-| test_cipher.rs:37:49:37:49 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
-| test_cipher.rs:37:52:37:52 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
-| test_cipher.rs:37:55:37:55 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
-| test_cipher.rs:37:58:37:58 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
-| test_cipher.rs:37:61:37:61 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
-| test_cipher.rs:37:64:37:64 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
-| test_cipher.rs:37:67:37:67 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
-| test_cipher.rs:37:70:37:70 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
-| test_cipher.rs:37:73:37:73 | 0 | test_cipher.rs:37:27:37:74 | [...] [element] | provenance | |
-| test_cipher.rs:38:49:38:80 | ...::from_slice(...) [&ref, element] | test_cipher.rs:38:30:38:47 | ...::new | provenance | MaD:58 Sink:MaD:58 Sink:MaD:58 |
-| test_cipher.rs:38:73:38:79 | &const7 [&ref, element] | test_cipher.rs:38:49:38:80 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
-| test_cipher.rs:38:74:38:79 | const7 [element] | test_cipher.rs:38:73:38:79 | &const7 [&ref, element] | provenance | |
-| test_cipher.rs:41:9:41:14 | const8 [&ref, element] | test_cipher.rs:42:73:42:78 | const8 [&ref, element] | provenance | |
-| test_cipher.rs:41:28:41:76 | &... [&ref, element] | test_cipher.rs:41:9:41:14 | const8 [&ref, element] | provenance | |
-| test_cipher.rs:41:29:41:76 | [...] [element] | test_cipher.rs:41:28:41:76 | &... [&ref, element] | provenance | |
-| test_cipher.rs:41:30:41:30 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
-| test_cipher.rs:41:33:41:33 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
-| test_cipher.rs:41:36:41:36 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
-| test_cipher.rs:41:39:41:39 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
-| test_cipher.rs:41:42:41:42 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
-| test_cipher.rs:41:45:41:45 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
-| test_cipher.rs:41:48:41:48 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
-| test_cipher.rs:41:51:41:51 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
-| test_cipher.rs:41:54:41:54 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
-| test_cipher.rs:41:57:41:57 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
-| test_cipher.rs:41:60:41:60 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
-| test_cipher.rs:41:63:41:63 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
-| test_cipher.rs:41:66:41:66 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
-| test_cipher.rs:41:69:41:69 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
-| test_cipher.rs:41:72:41:72 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
-| test_cipher.rs:41:75:41:75 | 0 | test_cipher.rs:41:29:41:76 | [...] [element] | provenance | |
-| test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref, element] | test_cipher.rs:42:30:42:47 | ...::new | provenance | MaD:58 Sink:MaD:58 Sink:MaD:58 |
-| test_cipher.rs:42:73:42:78 | const8 [&ref, element] | test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
+| test_cipher.rs:37:9:37:14 | const7 | test_cipher.rs:38:74:38:79 | const7 | provenance | |
+| test_cipher.rs:37:27:37:74 | [...] | test_cipher.rs:37:9:37:14 | const7 | provenance | |
+| test_cipher.rs:38:49:38:80 | ...::from_slice(...) [&ref] | test_cipher.rs:38:30:38:47 | ...::new | provenance | MaD:58 Sink:MaD:58 |
+| test_cipher.rs:38:73:38:79 | &const7 [&ref] | test_cipher.rs:38:49:38:80 | ...::from_slice(...) [&ref] | provenance | MaD:0 |
+| test_cipher.rs:38:74:38:79 | const7 | test_cipher.rs:38:73:38:79 | &const7 [&ref] | provenance | |
+| test_cipher.rs:41:9:41:14 | const8 [&ref] | test_cipher.rs:42:73:42:78 | const8 [&ref] | provenance | |
+| test_cipher.rs:41:28:41:76 | &... [&ref] | test_cipher.rs:41:9:41:14 | const8 [&ref] | provenance | |
+| test_cipher.rs:41:29:41:76 | [...] | test_cipher.rs:41:28:41:76 | &... [&ref] | provenance | |
+| test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref] | test_cipher.rs:42:30:42:47 | ...::new | provenance | MaD:58 Sink:MaD:58 |
+| test_cipher.rs:42:73:42:78 | const8 [&ref] | test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref] | provenance | MaD:0 |
| test_cipher.rs:73:9:73:14 | const2 [&ref, element] | test_cipher.rs:74:46:74:51 | const2 [&ref, element] | provenance | |
| test_cipher.rs:73:18:73:26 | &... [&ref, element] | test_cipher.rs:73:9:73:14 | const2 [&ref, element] | provenance | |
| test_cipher.rs:73:19:73:26 | [0u8; 32] [element] | test_cipher.rs:73:18:73:26 | &... [&ref, element] | provenance | |
@@ -123,50 +61,18 @@ nodes
| test_cipher.rs:30:30:30:40 | ...::new | semmle.label | ...::new |
| test_cipher.rs:30:72:30:101 | ...::from_slice(...) [&ref, element] | semmle.label | ...::from_slice(...) [&ref, element] |
| test_cipher.rs:30:95:30:100 | const5 [&ref, element] | semmle.label | const5 [&ref, element] |
-| test_cipher.rs:37:9:37:14 | const7 [element] | semmle.label | const7 [element] |
-| test_cipher.rs:37:27:37:74 | [...] [element] | semmle.label | [...] [element] |
-| test_cipher.rs:37:28:37:28 | 0 | semmle.label | 0 |
-| test_cipher.rs:37:31:37:31 | 0 | semmle.label | 0 |
-| test_cipher.rs:37:34:37:34 | 0 | semmle.label | 0 |
-| test_cipher.rs:37:37:37:37 | 0 | semmle.label | 0 |
-| test_cipher.rs:37:40:37:40 | 0 | semmle.label | 0 |
-| test_cipher.rs:37:43:37:43 | 0 | semmle.label | 0 |
-| test_cipher.rs:37:46:37:46 | 0 | semmle.label | 0 |
-| test_cipher.rs:37:49:37:49 | 0 | semmle.label | 0 |
-| test_cipher.rs:37:52:37:52 | 0 | semmle.label | 0 |
-| test_cipher.rs:37:55:37:55 | 0 | semmle.label | 0 |
-| test_cipher.rs:37:58:37:58 | 0 | semmle.label | 0 |
-| test_cipher.rs:37:61:37:61 | 0 | semmle.label | 0 |
-| test_cipher.rs:37:64:37:64 | 0 | semmle.label | 0 |
-| test_cipher.rs:37:67:37:67 | 0 | semmle.label | 0 |
-| test_cipher.rs:37:70:37:70 | 0 | semmle.label | 0 |
-| test_cipher.rs:37:73:37:73 | 0 | semmle.label | 0 |
+| test_cipher.rs:37:9:37:14 | const7 | semmle.label | const7 |
+| test_cipher.rs:37:27:37:74 | [...] | semmle.label | [...] |
| test_cipher.rs:38:30:38:47 | ...::new | semmle.label | ...::new |
-| test_cipher.rs:38:49:38:80 | ...::from_slice(...) [&ref, element] | semmle.label | ...::from_slice(...) [&ref, element] |
-| test_cipher.rs:38:73:38:79 | &const7 [&ref, element] | semmle.label | &const7 [&ref, element] |
-| test_cipher.rs:38:74:38:79 | const7 [element] | semmle.label | const7 [element] |
-| test_cipher.rs:41:9:41:14 | const8 [&ref, element] | semmle.label | const8 [&ref, element] |
-| test_cipher.rs:41:28:41:76 | &... [&ref, element] | semmle.label | &... [&ref, element] |
-| test_cipher.rs:41:29:41:76 | [...] [element] | semmle.label | [...] [element] |
-| test_cipher.rs:41:30:41:30 | 0 | semmle.label | 0 |
-| test_cipher.rs:41:33:41:33 | 0 | semmle.label | 0 |
-| test_cipher.rs:41:36:41:36 | 0 | semmle.label | 0 |
-| test_cipher.rs:41:39:41:39 | 0 | semmle.label | 0 |
-| test_cipher.rs:41:42:41:42 | 0 | semmle.label | 0 |
-| test_cipher.rs:41:45:41:45 | 0 | semmle.label | 0 |
-| test_cipher.rs:41:48:41:48 | 0 | semmle.label | 0 |
-| test_cipher.rs:41:51:41:51 | 0 | semmle.label | 0 |
-| test_cipher.rs:41:54:41:54 | 0 | semmle.label | 0 |
-| test_cipher.rs:41:57:41:57 | 0 | semmle.label | 0 |
-| test_cipher.rs:41:60:41:60 | 0 | semmle.label | 0 |
-| test_cipher.rs:41:63:41:63 | 0 | semmle.label | 0 |
-| test_cipher.rs:41:66:41:66 | 0 | semmle.label | 0 |
-| test_cipher.rs:41:69:41:69 | 0 | semmle.label | 0 |
-| test_cipher.rs:41:72:41:72 | 0 | semmle.label | 0 |
-| test_cipher.rs:41:75:41:75 | 0 | semmle.label | 0 |
+| test_cipher.rs:38:49:38:80 | ...::from_slice(...) [&ref] | semmle.label | ...::from_slice(...) [&ref] |
+| test_cipher.rs:38:73:38:79 | &const7 [&ref] | semmle.label | &const7 [&ref] |
+| test_cipher.rs:38:74:38:79 | const7 | semmle.label | const7 |
+| test_cipher.rs:41:9:41:14 | const8 [&ref] | semmle.label | const8 [&ref] |
+| test_cipher.rs:41:28:41:76 | &... [&ref] | semmle.label | &... [&ref] |
+| test_cipher.rs:41:29:41:76 | [...] | semmle.label | [...] |
| test_cipher.rs:42:30:42:47 | ...::new | semmle.label | ...::new |
-| test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref, element] | semmle.label | ...::from_slice(...) [&ref, element] |
-| test_cipher.rs:42:73:42:78 | const8 [&ref, element] | semmle.label | const8 [&ref, element] |
+| test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref] | semmle.label | ...::from_slice(...) [&ref] |
+| test_cipher.rs:42:73:42:78 | const8 [&ref] | semmle.label | const8 [&ref] |
| test_cipher.rs:73:9:73:14 | const2 [&ref, element] | semmle.label | const2 [&ref, element] |
| test_cipher.rs:73:18:73:26 | &... [&ref, element] | semmle.label | &... [&ref, element] |
| test_cipher.rs:73:19:73:26 | [0u8; 32] [element] | semmle.label | [0u8; 32] [element] |
From ac94ac6584cc0a8ab4e4c59793b412229b254a18 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Thu, 6 Mar 2025 16:25:27 +0000
Subject: [PATCH 007/534] Rust: Model even more sinks + flows.
---
.../rustcrypto/rustcrypto.model.yml | 2 +
.../frameworks/stdlib/lang-core.model.yml | 4 +
.../HardcodedCryptographicValueExtensions.qll | 4 +-
.../HardcodedCryptographicValue.expected | 123 ++++++++++++++++++
.../security/CWE-798/test_cipher.rs | 32 ++---
5 files changed, 148 insertions(+), 17 deletions(-)
diff --git a/rust/ql/lib/codeql/rust/frameworks/rustcrypto/rustcrypto.model.yml b/rust/ql/lib/codeql/rust/frameworks/rustcrypto/rustcrypto.model.yml
index 5b5b42ca309..2047cfa9ebc 100644
--- a/rust/ql/lib/codeql/rust/frameworks/rustcrypto/rustcrypto.model.yml
+++ b/rust/ql/lib/codeql/rust/frameworks/rustcrypto/rustcrypto.model.yml
@@ -40,3 +40,5 @@ extensions:
- ["repo:https://github.com/RustCrypto/traits:crypto-common", "<_ as crate::KeyIvInit>::new", "Argument[1]", "credentials-iv", "manual"]
- ["repo:https://github.com/RustCrypto/traits:crypto-common", "<_ as crate::KeyIvInit>::new_from_slices", "Argument[0]", "credentials-key", "manual"]
- ["repo:https://github.com/RustCrypto/traits:crypto-common", "<_ as crate::KeyIvInit>::new_from_slices", "Argument[1]", "credentials-iv", "manual"]
+ - ["repo:https://github.com/RustCrypto/AEADs:aes-gcm", "::new", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/traits:aead", "<_ as crate::Aead>::encrypt", "Argument[0]", "credentials-nonce", "manual"]
diff --git a/rust/ql/lib/codeql/rust/frameworks/stdlib/lang-core.model.yml b/rust/ql/lib/codeql/rust/frameworks/stdlib/lang-core.model.yml
index 062576e46bb..d8bbe389eaa 100644
--- a/rust/ql/lib/codeql/rust/frameworks/stdlib/lang-core.model.yml
+++ b/rust/ql/lib/codeql/rust/frameworks/stdlib/lang-core.model.yml
@@ -3,6 +3,10 @@ extensions:
pack: codeql/rust-all
extensible: summaryModel
data:
+ # Conversions
+ - ["lang:core", "<_ as crate::convert::Into>::into", "Argument[self].Element", "ReturnValue.Element", "taint", "manual"]
+ - ["lang:core", "<_ as crate::convert::Into>::into", "Argument[self].Reference.Element", "ReturnValue.Element", "taint", "manual"]
+ - ["lang:core", "<[_]>::align_to", "Argument[self].Element", "ReturnValue.Field[0,1,2].Reference.Element", "taint", "manual"]
# Fmt
- ["lang:alloc", "crate::fmt::format", "Argument[0]", "ReturnValue", "taint", "manual"]
# Iterator
diff --git a/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll b/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
index f7f26032b51..fbabffc3e28 100644
--- a/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
+++ b/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
@@ -12,7 +12,7 @@ private import codeql.rust.security.SensitiveData
* A kind of cryptographic value.
*/
class CryptographicValueKind extends string {
- CryptographicValueKind() { this = ["password", "key", "iv", "salt"] }
+ CryptographicValueKind() { this = ["password", "key", "iv", "nonce", "salt"] }
/**
* Gets a description of this value kind for user-facing messages.
@@ -24,6 +24,8 @@ class CryptographicValueKind extends string {
or
this = "iv" and result = "an initialization vector"
or
+ this = "nonce" and result = "a nonce"
+ or
this = "salt" and result = "a salt"
}
}
diff --git a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
index 2ed68852eb5..0d29ab6921c 100644
--- a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
+++ b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
@@ -4,7 +4,15 @@
| test_cipher.rs:29:30:29:32 | 0u8 | test_cipher.rs:29:30:29:32 | 0u8 | test_cipher.rs:30:30:30:40 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:30:30:30:40 | ...::new | an initialization vector |
| test_cipher.rs:37:27:37:74 | [...] | test_cipher.rs:37:27:37:74 | [...] | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
| test_cipher.rs:41:29:41:76 | [...] | test_cipher.rs:41:29:41:76 | [...] | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
+| test_cipher.rs:45:27:45:50 | [...] | test_cipher.rs:45:27:45:50 | [...] | test_cipher.rs:47:30:47:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:47:30:47:47 | ...::new | a key |
+| test_cipher.rs:66:20:66:22 | 0u8 | test_cipher.rs:66:20:66:22 | 0u8 | test_cipher.rs:67:23:67:33 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:67:23:67:33 | ...::new | a key |
| test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:74:23:74:44 | ...::new_from_slice | This hard-coded value is used as $@. | test_cipher.rs:74:23:74:44 | ...::new_from_slice | a key |
+| test_cipher.rs:80:20:80:22 | 0u8 | test_cipher.rs:80:20:80:22 | 0u8 | test_cipher.rs:81:23:81:61 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:81:23:81:61 | ...::new | a key |
+| test_cipher.rs:84:20:84:22 | 0u8 | test_cipher.rs:84:20:84:22 | 0u8 | test_cipher.rs:85:23:85:61 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:85:23:85:61 | ...::new | an initialization vector |
+| test_cipher.rs:124:26:124:26 | 0 | test_cipher.rs:124:26:124:26 | 0 | test_cipher.rs:126:19:126:32 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:126:19:126:32 | ...::new | a key |
+| test_cipher.rs:125:19:125:19 | 0 | test_cipher.rs:125:19:125:19 | 0 | test_cipher.rs:127:21:127:27 | encrypt | This hard-coded value is used as $@. | test_cipher.rs:127:21:127:27 | encrypt | a nonce |
+| test_cipher.rs:129:34:129:37 | 0xff | test_cipher.rs:129:34:129:37 | 0xff | test_cipher.rs:132:19:132:32 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:132:19:132:32 | ...::new | a key |
+| test_cipher.rs:131:28:131:31 | 0xff | test_cipher.rs:131:28:131:31 | 0xff | test_cipher.rs:133:21:133:27 | encrypt | This hard-coded value is used as $@. | test_cipher.rs:133:21:133:27 | encrypt | a nonce |
edges
| test_cipher.rs:18:9:18:14 | const1 [&ref, element] | test_cipher.rs:19:73:19:78 | const1 [&ref, element] | provenance | |
| test_cipher.rs:18:28:18:36 | &... [&ref, element] | test_cipher.rs:18:9:18:14 | const1 [&ref, element] | provenance | |
@@ -34,11 +42,65 @@ edges
| test_cipher.rs:41:29:41:76 | [...] | test_cipher.rs:41:28:41:76 | &... [&ref] | provenance | |
| test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref] | test_cipher.rs:42:30:42:47 | ...::new | provenance | MaD:58 Sink:MaD:58 |
| test_cipher.rs:42:73:42:78 | const8 [&ref] | test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref] | provenance | MaD:0 |
+| test_cipher.rs:45:9:45:14 | const9 | test_cipher.rs:46:32:46:37 | const9 | provenance | |
+| test_cipher.rs:45:27:45:50 | [...] | test_cipher.rs:45:9:45:14 | const9 | provenance | |
+| test_cipher.rs:46:9:46:19 | const9_conv [&ref, element] | test_cipher.rs:47:73:47:83 | const9_conv [&ref, element] | provenance | |
+| test_cipher.rs:46:32:46:37 | const9 | test_cipher.rs:46:32:46:54 | const9.align_to(...) [tuple.1, &ref, element] | provenance | MaD:103 |
+| test_cipher.rs:46:32:46:54 | const9.align_to(...) [tuple.1, &ref, element] | test_cipher.rs:46:32:46:56 | ... .1 [&ref, element] | provenance | |
+| test_cipher.rs:46:32:46:56 | ... .1 [&ref, element] | test_cipher.rs:46:9:46:19 | const9_conv [&ref, element] | provenance | |
+| test_cipher.rs:47:49:47:84 | ...::from_slice(...) [&ref, element] | test_cipher.rs:47:30:47:47 | ...::new | provenance | MaD:58 Sink:MaD:58 Sink:MaD:58 |
+| test_cipher.rs:47:73:47:83 | const9_conv [&ref, element] | test_cipher.rs:47:49:47:84 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
+| test_cipher.rs:66:9:66:14 | const2 [&ref, element] | test_cipher.rs:67:35:67:40 | const2 [&ref, element] | provenance | |
+| test_cipher.rs:66:18:66:26 | &... [&ref, element] | test_cipher.rs:66:9:66:14 | const2 [&ref, element] | provenance | |
+| test_cipher.rs:66:19:66:26 | [0u8; 32] [element] | test_cipher.rs:66:18:66:26 | &... [&ref, element] | provenance | |
+| test_cipher.rs:66:20:66:22 | 0u8 | test_cipher.rs:66:19:66:26 | [0u8; 32] [element] | provenance | |
+| test_cipher.rs:67:35:67:40 | const2 [&ref, element] | test_cipher.rs:67:35:67:47 | const2.into(...) [element] | provenance | MaD:102 |
+| test_cipher.rs:67:35:67:47 | const2.into(...) [element] | test_cipher.rs:67:23:67:33 | ...::new | provenance | MaD:76 Sink:MaD:76 |
| test_cipher.rs:73:9:73:14 | const2 [&ref, element] | test_cipher.rs:74:46:74:51 | const2 [&ref, element] | provenance | |
| test_cipher.rs:73:18:73:26 | &... [&ref, element] | test_cipher.rs:73:9:73:14 | const2 [&ref, element] | provenance | |
| test_cipher.rs:73:19:73:26 | [0u8; 32] [element] | test_cipher.rs:73:18:73:26 | &... [&ref, element] | provenance | |
| test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:73:19:73:26 | [0u8; 32] [element] | provenance | |
| test_cipher.rs:74:46:74:51 | const2 [&ref, element] | test_cipher.rs:74:23:74:44 | ...::new_from_slice | provenance | MaD:84 Sink:MaD:84 Sink:MaD:84 |
+| test_cipher.rs:80:9:80:14 | const6 [&ref, element] | test_cipher.rs:81:63:81:68 | const6 [&ref, element] | provenance | |
+| test_cipher.rs:80:18:80:26 | &... [&ref, element] | test_cipher.rs:80:9:80:14 | const6 [&ref, element] | provenance | |
+| test_cipher.rs:80:19:80:26 | [0u8; 32] [element] | test_cipher.rs:80:18:80:26 | &... [&ref, element] | provenance | |
+| test_cipher.rs:80:20:80:22 | 0u8 | test_cipher.rs:80:19:80:26 | [0u8; 32] [element] | provenance | |
+| test_cipher.rs:81:63:81:68 | const6 [&ref, element] | test_cipher.rs:81:63:81:75 | const6.into(...) [element] | provenance | MaD:102 |
+| test_cipher.rs:81:63:81:75 | const6.into(...) [element] | test_cipher.rs:81:23:81:61 | ...::new | provenance | MaD:86 Sink:MaD:86 |
+| test_cipher.rs:84:9:84:14 | const7 [&ref, element] | test_cipher.rs:85:75:85:80 | const7 [&ref, element] | provenance | |
+| test_cipher.rs:84:18:84:27 | &... [&ref, element] | test_cipher.rs:84:9:84:14 | const7 [&ref, element] | provenance | |
+| test_cipher.rs:84:19:84:27 | [0u8; 16] [element] | test_cipher.rs:84:18:84:27 | &... [&ref, element] | provenance | |
+| test_cipher.rs:84:20:84:22 | 0u8 | test_cipher.rs:84:19:84:27 | [0u8; 16] [element] | provenance | |
+| test_cipher.rs:85:75:85:80 | const7 [&ref, element] | test_cipher.rs:85:75:85:87 | const7.into(...) [element] | provenance | MaD:102 |
+| test_cipher.rs:85:75:85:87 | const7.into(...) [element] | test_cipher.rs:85:23:85:61 | ...::new | provenance | MaD:87 Sink:MaD:87 |
+| test_cipher.rs:124:9:124:12 | key2 [element] | test_cipher.rs:126:35:126:38 | key2 [element] | provenance | |
+| test_cipher.rs:124:25:124:30 | [0; 32] [element] | test_cipher.rs:124:9:124:12 | key2 [element] | provenance | |
+| test_cipher.rs:124:26:124:26 | 0 | test_cipher.rs:124:25:124:30 | [0; 32] [element] | provenance | |
+| test_cipher.rs:125:9:125:14 | nonce2 [element] | test_cipher.rs:127:30:127:35 | nonce2 [element] | provenance | |
+| test_cipher.rs:125:18:125:23 | [0; 12] [element] | test_cipher.rs:125:9:125:14 | nonce2 [element] | provenance | |
+| test_cipher.rs:125:19:125:19 | 0 | test_cipher.rs:125:18:125:23 | [0; 12] [element] | provenance | |
+| test_cipher.rs:126:34:126:45 | &... [&ref, element] | test_cipher.rs:126:19:126:32 | ...::new | provenance | MaD:90 Sink:MaD:90 Sink:MaD:90 |
+| test_cipher.rs:126:35:126:38 | key2 [element] | test_cipher.rs:126:35:126:45 | key2.into(...) [element] | provenance | MaD:101 |
+| test_cipher.rs:126:35:126:45 | key2.into(...) [element] | test_cipher.rs:126:34:126:45 | &... [&ref, element] | provenance | |
+| test_cipher.rs:127:29:127:42 | &... [&ref, element] | test_cipher.rs:127:21:127:27 | encrypt | provenance | MaD:91 Sink:MaD:91 Sink:MaD:91 |
+| test_cipher.rs:127:30:127:35 | nonce2 [element] | test_cipher.rs:127:30:127:42 | nonce2.into(...) [element] | provenance | MaD:101 |
+| test_cipher.rs:127:30:127:42 | nonce2.into(...) [element] | test_cipher.rs:127:29:127:42 | &... [&ref, element] | provenance | |
+| test_cipher.rs:129:9:129:18 | key3_array [&ref, element] | test_cipher.rs:130:45:130:54 | key3_array [&ref, element] | provenance | |
+| test_cipher.rs:129:32:129:41 | &... [&ref, element] | test_cipher.rs:129:9:129:18 | key3_array [&ref, element] | provenance | |
+| test_cipher.rs:129:33:129:41 | [0xff; 32] [element] | test_cipher.rs:129:32:129:41 | &... [&ref, element] | provenance | |
+| test_cipher.rs:129:34:129:37 | 0xff | test_cipher.rs:129:33:129:41 | [0xff; 32] [element] | provenance | |
+| test_cipher.rs:130:9:130:12 | key3 [&ref, element] | test_cipher.rs:132:35:132:38 | key3 [&ref, element] | provenance | |
+| test_cipher.rs:130:16:130:55 | ...::from_slice(...) [&ref, element] | test_cipher.rs:130:9:130:12 | key3 [&ref, element] | provenance | |
+| test_cipher.rs:130:45:130:54 | key3_array [&ref, element] | test_cipher.rs:130:16:130:55 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
+| test_cipher.rs:131:9:131:14 | nonce3 [element] | test_cipher.rs:133:30:133:35 | nonce3 [element] | provenance | |
+| test_cipher.rs:131:27:131:35 | [0xff; 12] [element] | test_cipher.rs:131:9:131:14 | nonce3 [element] | provenance | |
+| test_cipher.rs:131:28:131:31 | 0xff | test_cipher.rs:131:27:131:35 | [0xff; 12] [element] | provenance | |
+| test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | test_cipher.rs:132:19:132:32 | ...::new | provenance | MaD:90 Sink:MaD:90 Sink:MaD:90 |
+| test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | test_cipher.rs:132:19:132:32 | ...::new | provenance | MaD:90 Sink:MaD:90 Sink:MaD:90 Sink:MaD:90 |
+| test_cipher.rs:132:35:132:38 | key3 [&ref, element] | test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | provenance | |
+| test_cipher.rs:133:29:133:42 | &... [&ref, element] | test_cipher.rs:133:21:133:27 | encrypt | provenance | MaD:91 Sink:MaD:91 Sink:MaD:91 |
+| test_cipher.rs:133:30:133:35 | nonce3 [element] | test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | provenance | MaD:101 |
+| test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | test_cipher.rs:133:29:133:42 | &... [&ref, element] | provenance | |
nodes
| test_cipher.rs:18:9:18:14 | const1 [&ref, element] | semmle.label | const1 [&ref, element] |
| test_cipher.rs:18:28:18:36 | &... [&ref, element] | semmle.label | &... [&ref, element] |
@@ -73,10 +135,71 @@ nodes
| test_cipher.rs:42:30:42:47 | ...::new | semmle.label | ...::new |
| test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref] | semmle.label | ...::from_slice(...) [&ref] |
| test_cipher.rs:42:73:42:78 | const8 [&ref] | semmle.label | const8 [&ref] |
+| test_cipher.rs:45:9:45:14 | const9 | semmle.label | const9 |
+| test_cipher.rs:45:27:45:50 | [...] | semmle.label | [...] |
+| test_cipher.rs:46:9:46:19 | const9_conv [&ref, element] | semmle.label | const9_conv [&ref, element] |
+| test_cipher.rs:46:32:46:37 | const9 | semmle.label | const9 |
+| test_cipher.rs:46:32:46:54 | const9.align_to(...) [tuple.1, &ref, element] | semmle.label | const9.align_to(...) [tuple.1, &ref, element] |
+| test_cipher.rs:46:32:46:56 | ... .1 [&ref, element] | semmle.label | ... .1 [&ref, element] |
+| test_cipher.rs:47:30:47:47 | ...::new | semmle.label | ...::new |
+| test_cipher.rs:47:49:47:84 | ...::from_slice(...) [&ref, element] | semmle.label | ...::from_slice(...) [&ref, element] |
+| test_cipher.rs:47:73:47:83 | const9_conv [&ref, element] | semmle.label | const9_conv [&ref, element] |
+| test_cipher.rs:66:9:66:14 | const2 [&ref, element] | semmle.label | const2 [&ref, element] |
+| test_cipher.rs:66:18:66:26 | &... [&ref, element] | semmle.label | &... [&ref, element] |
+| test_cipher.rs:66:19:66:26 | [0u8; 32] [element] | semmle.label | [0u8; 32] [element] |
+| test_cipher.rs:66:20:66:22 | 0u8 | semmle.label | 0u8 |
+| test_cipher.rs:67:23:67:33 | ...::new | semmle.label | ...::new |
+| test_cipher.rs:67:35:67:40 | const2 [&ref, element] | semmle.label | const2 [&ref, element] |
+| test_cipher.rs:67:35:67:47 | const2.into(...) [element] | semmle.label | const2.into(...) [element] |
| test_cipher.rs:73:9:73:14 | const2 [&ref, element] | semmle.label | const2 [&ref, element] |
| test_cipher.rs:73:18:73:26 | &... [&ref, element] | semmle.label | &... [&ref, element] |
| test_cipher.rs:73:19:73:26 | [0u8; 32] [element] | semmle.label | [0u8; 32] [element] |
| test_cipher.rs:73:20:73:22 | 0u8 | semmle.label | 0u8 |
| test_cipher.rs:74:23:74:44 | ...::new_from_slice | semmle.label | ...::new_from_slice |
| test_cipher.rs:74:46:74:51 | const2 [&ref, element] | semmle.label | const2 [&ref, element] |
+| test_cipher.rs:80:9:80:14 | const6 [&ref, element] | semmle.label | const6 [&ref, element] |
+| test_cipher.rs:80:18:80:26 | &... [&ref, element] | semmle.label | &... [&ref, element] |
+| test_cipher.rs:80:19:80:26 | [0u8; 32] [element] | semmle.label | [0u8; 32] [element] |
+| test_cipher.rs:80:20:80:22 | 0u8 | semmle.label | 0u8 |
+| test_cipher.rs:81:23:81:61 | ...::new | semmle.label | ...::new |
+| test_cipher.rs:81:63:81:68 | const6 [&ref, element] | semmle.label | const6 [&ref, element] |
+| test_cipher.rs:81:63:81:75 | const6.into(...) [element] | semmle.label | const6.into(...) [element] |
+| test_cipher.rs:84:9:84:14 | const7 [&ref, element] | semmle.label | const7 [&ref, element] |
+| test_cipher.rs:84:18:84:27 | &... [&ref, element] | semmle.label | &... [&ref, element] |
+| test_cipher.rs:84:19:84:27 | [0u8; 16] [element] | semmle.label | [0u8; 16] [element] |
+| test_cipher.rs:84:20:84:22 | 0u8 | semmle.label | 0u8 |
+| test_cipher.rs:85:23:85:61 | ...::new | semmle.label | ...::new |
+| test_cipher.rs:85:75:85:80 | const7 [&ref, element] | semmle.label | const7 [&ref, element] |
+| test_cipher.rs:85:75:85:87 | const7.into(...) [element] | semmle.label | const7.into(...) [element] |
+| test_cipher.rs:124:9:124:12 | key2 [element] | semmle.label | key2 [element] |
+| test_cipher.rs:124:25:124:30 | [0; 32] [element] | semmle.label | [0; 32] [element] |
+| test_cipher.rs:124:26:124:26 | 0 | semmle.label | 0 |
+| test_cipher.rs:125:9:125:14 | nonce2 [element] | semmle.label | nonce2 [element] |
+| test_cipher.rs:125:18:125:23 | [0; 12] [element] | semmle.label | [0; 12] [element] |
+| test_cipher.rs:125:19:125:19 | 0 | semmle.label | 0 |
+| test_cipher.rs:126:19:126:32 | ...::new | semmle.label | ...::new |
+| test_cipher.rs:126:34:126:45 | &... [&ref, element] | semmle.label | &... [&ref, element] |
+| test_cipher.rs:126:35:126:38 | key2 [element] | semmle.label | key2 [element] |
+| test_cipher.rs:126:35:126:45 | key2.into(...) [element] | semmle.label | key2.into(...) [element] |
+| test_cipher.rs:127:21:127:27 | encrypt | semmle.label | encrypt |
+| test_cipher.rs:127:29:127:42 | &... [&ref, element] | semmle.label | &... [&ref, element] |
+| test_cipher.rs:127:30:127:35 | nonce2 [element] | semmle.label | nonce2 [element] |
+| test_cipher.rs:127:30:127:42 | nonce2.into(...) [element] | semmle.label | nonce2.into(...) [element] |
+| test_cipher.rs:129:9:129:18 | key3_array [&ref, element] | semmle.label | key3_array [&ref, element] |
+| test_cipher.rs:129:32:129:41 | &... [&ref, element] | semmle.label | &... [&ref, element] |
+| test_cipher.rs:129:33:129:41 | [0xff; 32] [element] | semmle.label | [0xff; 32] [element] |
+| test_cipher.rs:129:34:129:37 | 0xff | semmle.label | 0xff |
+| test_cipher.rs:130:9:130:12 | key3 [&ref, element] | semmle.label | key3 [&ref, element] |
+| test_cipher.rs:130:16:130:55 | ...::from_slice(...) [&ref, element] | semmle.label | ...::from_slice(...) [&ref, element] |
+| test_cipher.rs:130:45:130:54 | key3_array [&ref, element] | semmle.label | key3_array [&ref, element] |
+| test_cipher.rs:131:9:131:14 | nonce3 [element] | semmle.label | nonce3 [element] |
+| test_cipher.rs:131:27:131:35 | [0xff; 12] [element] | semmle.label | [0xff; 12] [element] |
+| test_cipher.rs:131:28:131:31 | 0xff | semmle.label | 0xff |
+| test_cipher.rs:132:19:132:32 | ...::new | semmle.label | ...::new |
+| test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | semmle.label | &key3 [&ref, &ref, element] |
+| test_cipher.rs:132:35:132:38 | key3 [&ref, element] | semmle.label | key3 [&ref, element] |
+| test_cipher.rs:133:21:133:27 | encrypt | semmle.label | encrypt |
+| test_cipher.rs:133:29:133:42 | &... [&ref, element] | semmle.label | &... [&ref, element] |
+| test_cipher.rs:133:30:133:35 | nonce3 [element] | semmle.label | nonce3 [element] |
+| test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | semmle.label | nonce3.into(...) [element] |
subpaths
diff --git a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
index cfa20ab13c2..d85fffcf58a 100644
--- a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
+++ b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
@@ -42,9 +42,9 @@ fn test_stream_cipher_rabbit(
let mut rabbit_cipher8 = RabbitKeyOnly::new(rabbit::Key::from_slice(const8)); // $ Sink
rabbit_cipher8.apply_keystream(&mut data);
- let const9: [u16;8] = [0, 0, 0, 0, 0, 0, 0, 0]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let const9: [u16;8] = [0, 0, 0, 0, 0, 0, 0, 0]; // $ Alert[rust/hardcoded-crytographic-value]
let const9_conv = unsafe { const9.align_to::().1 }; // convert [u16;8] -> [u8;8]
- let mut rabbit_cipher9 = RabbitKeyOnly::new(rabbit::Key::from_slice(const9_conv));
+ let mut rabbit_cipher9 = RabbitKeyOnly::new(rabbit::Key::from_slice(const9_conv)); // $ Sink
rabbit_cipher9.apply_keystream(&mut data);
let const10: [u8;16] = unsafe { std::mem::zeroed() }; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
@@ -63,8 +63,8 @@ fn test_block_cipher_aes(
let aes_cipher1 = Aes256::new(key256.into());
aes_cipher1.encrypt_block(block128.into());
- let const2 = &[0u8;32]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
- let aes_cipher2 = Aes256::new(const2.into());
+ let const2 = &[0u8;32]; // $ Alert[rust/hardcoded-crytographic-value]
+ let aes_cipher2 = Aes256::new(const2.into()); // $ Sink
aes_cipher2.encrypt_block(block128.into());
let aes_cipher3 = Aes256::new_from_slice(key256).unwrap();
@@ -77,12 +77,12 @@ fn test_block_cipher_aes(
let aes_cipher5 = cfb_mode::Encryptor::::new(key.into(), iv.into());
_ = aes_cipher5.encrypt_b2b(input, output).unwrap();
- let const6 = &[0u8;32]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
- let aes_cipher6 = cfb_mode::Encryptor::::new(const6.into(), iv.into());
+ let const6 = &[0u8;32]; // $ Alert[rust/hardcoded-crytographic-value]
+ let aes_cipher6 = cfb_mode::Encryptor::::new(const6.into(), iv.into()); // $ Sink
_ = aes_cipher6.encrypt_b2b(input, output).unwrap();
- let const7 = &[0u8; 16]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
- let aes_cipher7 = cfb_mode::Encryptor::::new(key.into(), const7.into());
+ let const7 = &[0u8; 16]; // $ Alert[rust/hardcoded-crytographic-value]
+ let aes_cipher7 = cfb_mode::Encryptor::::new(key.into(), const7.into()); // $ Sink
_ = aes_cipher7.encrypt_b2b(input, output).unwrap();
// various string conversions
@@ -121,14 +121,14 @@ fn test_aes_gcm(
let cipher1 = Aes256Gcm::new(&key1);
let _ = cipher1.encrypt(&nonce1, b"plaintext".as_ref()).unwrap();
- let key2: [u8;32] = [0;32]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
- let nonce2 = [0;12]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
- let cipher2 = Aes256Gcm::new(&key2.into());
- let _ = cipher2.encrypt(&nonce2.into(), b"plaintext".as_ref()).unwrap();
+ let key2: [u8;32] = [0;32]; // $ Alert[rust/hardcoded-crytographic-value]
+ let nonce2 = [0;12]; // $ Alert[rust/hardcoded-crytographic-value]
+ let cipher2 = Aes256Gcm::new(&key2.into()); // $ Sink
+ let _ = cipher2.encrypt(&nonce2.into(), b"plaintext".as_ref()).unwrap(); // $ Sink
- let key3_array: &[u8;32] = &[0xff;32]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let key3_array: &[u8;32] = &[0xff;32]; // $ Alert[rust/hardcoded-crytographic-value]
let key3 = Key::::from_slice(key3_array);
- let nonce3: [u8;12] = [0xff;12]; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
- let cipher3 = Aes256Gcm::new(&key3);
- let _ = cipher3.encrypt(&nonce3.into(), b"plaintext".as_ref()).unwrap();
+ let nonce3: [u8;12] = [0xff;12]; // $ Alert[rust/hardcoded-crytographic-value]
+ let cipher3 = Aes256Gcm::new(&key3); // $ Sink
+ let _ = cipher3.encrypt(&nonce3.into(), b"plaintext".as_ref()).unwrap(); // $ Sink
}
From b4a6063e203222ea4319380f01e380fd1a0754ca Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Thu, 6 Mar 2025 17:13:51 +0000
Subject: [PATCH 008/534] Rust: Add std::mem::zeroed as a source.
---
.../frameworks/stdlib/lang-core.model.yml | 5 ++++
.../HardcodedCryptographicValueExtensions.qll | 11 ++++++--
.../HardcodedCryptographicValue.expected | 28 ++++++++++++++-----
.../security/CWE-798/test_cipher.rs | 4 +--
4 files changed, 36 insertions(+), 12 deletions(-)
diff --git a/rust/ql/lib/codeql/rust/frameworks/stdlib/lang-core.model.yml b/rust/ql/lib/codeql/rust/frameworks/stdlib/lang-core.model.yml
index d8bbe389eaa..37f574dd2b8 100644
--- a/rust/ql/lib/codeql/rust/frameworks/stdlib/lang-core.model.yml
+++ b/rust/ql/lib/codeql/rust/frameworks/stdlib/lang-core.model.yml
@@ -1,4 +1,9 @@
extensions:
+ - addsTo:
+ pack: codeql/rust-all
+ extensible: sourceModel
+ data:
+ - ["lang:core", "crate::mem::zeroed", "ReturnValue.Element", "constant-source", "manual"]
- addsTo:
pack: codeql/rust-all
extensible: summaryModel
diff --git a/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll b/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
index fbabffc3e28..4d6210cb97b 100644
--- a/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
+++ b/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
@@ -69,9 +69,14 @@ module HardcodedCryptographicValue {
* ```
*/
private class ArrayListSource extends Source {
- ArrayListSource() {
- this.asExpr().getExpr().(ArrayListExpr).getExpr(_) instanceof LiteralExpr
- }
+ ArrayListSource() { this.asExpr().getExpr().(ArrayListExpr).getExpr(_) instanceof LiteralExpr }
+ }
+
+ /**
+ * An externally modeled source for constant values.
+ */
+ private class ModeledSource extends Source {
+ ModeledSource() { sourceNode(this, "constant-source") }
}
/**
diff --git a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
index 0d29ab6921c..a09f89d2127 100644
--- a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
+++ b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
@@ -5,6 +5,7 @@
| test_cipher.rs:37:27:37:74 | [...] | test_cipher.rs:37:27:37:74 | [...] | test_cipher.rs:38:30:38:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:38:30:38:47 | ...::new | a key |
| test_cipher.rs:41:29:41:76 | [...] | test_cipher.rs:41:29:41:76 | [...] | test_cipher.rs:42:30:42:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:42:30:42:47 | ...::new | a key |
| test_cipher.rs:45:27:45:50 | [...] | test_cipher.rs:45:27:45:50 | [...] | test_cipher.rs:47:30:47:47 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:47:30:47:47 | ...::new | a key |
+| test_cipher.rs:50:37:50:52 | ...::zeroed | test_cipher.rs:50:37:50:52 | ...::zeroed | test_cipher.rs:51:31:51:48 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:51:31:51:48 | ...::new | a key |
| test_cipher.rs:66:20:66:22 | 0u8 | test_cipher.rs:66:20:66:22 | 0u8 | test_cipher.rs:67:23:67:33 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:67:23:67:33 | ...::new | a key |
| test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:74:23:74:44 | ...::new_from_slice | This hard-coded value is used as $@. | test_cipher.rs:74:23:74:44 | ...::new_from_slice | a key |
| test_cipher.rs:80:20:80:22 | 0u8 | test_cipher.rs:80:20:80:22 | 0u8 | test_cipher.rs:81:23:81:61 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:81:23:81:61 | ...::new | a key |
@@ -45,16 +46,22 @@ edges
| test_cipher.rs:45:9:45:14 | const9 | test_cipher.rs:46:32:46:37 | const9 | provenance | |
| test_cipher.rs:45:27:45:50 | [...] | test_cipher.rs:45:9:45:14 | const9 | provenance | |
| test_cipher.rs:46:9:46:19 | const9_conv [&ref, element] | test_cipher.rs:47:73:47:83 | const9_conv [&ref, element] | provenance | |
-| test_cipher.rs:46:32:46:37 | const9 | test_cipher.rs:46:32:46:54 | const9.align_to(...) [tuple.1, &ref, element] | provenance | MaD:103 |
+| test_cipher.rs:46:32:46:37 | const9 | test_cipher.rs:46:32:46:54 | const9.align_to(...) [tuple.1, &ref, element] | provenance | MaD:104 |
| test_cipher.rs:46:32:46:54 | const9.align_to(...) [tuple.1, &ref, element] | test_cipher.rs:46:32:46:56 | ... .1 [&ref, element] | provenance | |
| test_cipher.rs:46:32:46:56 | ... .1 [&ref, element] | test_cipher.rs:46:9:46:19 | const9_conv [&ref, element] | provenance | |
| test_cipher.rs:47:49:47:84 | ...::from_slice(...) [&ref, element] | test_cipher.rs:47:30:47:47 | ...::new | provenance | MaD:58 Sink:MaD:58 Sink:MaD:58 |
| test_cipher.rs:47:73:47:83 | const9_conv [&ref, element] | test_cipher.rs:47:49:47:84 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
+| test_cipher.rs:50:9:50:15 | const10 [element] | test_cipher.rs:51:75:51:81 | const10 [element] | provenance | |
+| test_cipher.rs:50:37:50:52 | ...::zeroed | test_cipher.rs:50:37:50:54 | ...::zeroed(...) [element] | provenance | Src:MaD:101 |
+| test_cipher.rs:50:37:50:54 | ...::zeroed(...) [element] | test_cipher.rs:50:9:50:15 | const10 [element] | provenance | |
+| test_cipher.rs:51:50:51:82 | ...::from_slice(...) [&ref, element] | test_cipher.rs:51:31:51:48 | ...::new | provenance | MaD:58 Sink:MaD:58 Sink:MaD:58 |
+| test_cipher.rs:51:74:51:81 | &const10 [&ref, element] | test_cipher.rs:51:50:51:82 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
+| test_cipher.rs:51:75:51:81 | const10 [element] | test_cipher.rs:51:74:51:81 | &const10 [&ref, element] | provenance | |
| test_cipher.rs:66:9:66:14 | const2 [&ref, element] | test_cipher.rs:67:35:67:40 | const2 [&ref, element] | provenance | |
| test_cipher.rs:66:18:66:26 | &... [&ref, element] | test_cipher.rs:66:9:66:14 | const2 [&ref, element] | provenance | |
| test_cipher.rs:66:19:66:26 | [0u8; 32] [element] | test_cipher.rs:66:18:66:26 | &... [&ref, element] | provenance | |
| test_cipher.rs:66:20:66:22 | 0u8 | test_cipher.rs:66:19:66:26 | [0u8; 32] [element] | provenance | |
-| test_cipher.rs:67:35:67:40 | const2 [&ref, element] | test_cipher.rs:67:35:67:47 | const2.into(...) [element] | provenance | MaD:102 |
+| test_cipher.rs:67:35:67:40 | const2 [&ref, element] | test_cipher.rs:67:35:67:47 | const2.into(...) [element] | provenance | MaD:103 |
| test_cipher.rs:67:35:67:47 | const2.into(...) [element] | test_cipher.rs:67:23:67:33 | ...::new | provenance | MaD:76 Sink:MaD:76 |
| test_cipher.rs:73:9:73:14 | const2 [&ref, element] | test_cipher.rs:74:46:74:51 | const2 [&ref, element] | provenance | |
| test_cipher.rs:73:18:73:26 | &... [&ref, element] | test_cipher.rs:73:9:73:14 | const2 [&ref, element] | provenance | |
@@ -65,13 +72,13 @@ edges
| test_cipher.rs:80:18:80:26 | &... [&ref, element] | test_cipher.rs:80:9:80:14 | const6 [&ref, element] | provenance | |
| test_cipher.rs:80:19:80:26 | [0u8; 32] [element] | test_cipher.rs:80:18:80:26 | &... [&ref, element] | provenance | |
| test_cipher.rs:80:20:80:22 | 0u8 | test_cipher.rs:80:19:80:26 | [0u8; 32] [element] | provenance | |
-| test_cipher.rs:81:63:81:68 | const6 [&ref, element] | test_cipher.rs:81:63:81:75 | const6.into(...) [element] | provenance | MaD:102 |
+| test_cipher.rs:81:63:81:68 | const6 [&ref, element] | test_cipher.rs:81:63:81:75 | const6.into(...) [element] | provenance | MaD:103 |
| test_cipher.rs:81:63:81:75 | const6.into(...) [element] | test_cipher.rs:81:23:81:61 | ...::new | provenance | MaD:86 Sink:MaD:86 |
| test_cipher.rs:84:9:84:14 | const7 [&ref, element] | test_cipher.rs:85:75:85:80 | const7 [&ref, element] | provenance | |
| test_cipher.rs:84:18:84:27 | &... [&ref, element] | test_cipher.rs:84:9:84:14 | const7 [&ref, element] | provenance | |
| test_cipher.rs:84:19:84:27 | [0u8; 16] [element] | test_cipher.rs:84:18:84:27 | &... [&ref, element] | provenance | |
| test_cipher.rs:84:20:84:22 | 0u8 | test_cipher.rs:84:19:84:27 | [0u8; 16] [element] | provenance | |
-| test_cipher.rs:85:75:85:80 | const7 [&ref, element] | test_cipher.rs:85:75:85:87 | const7.into(...) [element] | provenance | MaD:102 |
+| test_cipher.rs:85:75:85:80 | const7 [&ref, element] | test_cipher.rs:85:75:85:87 | const7.into(...) [element] | provenance | MaD:103 |
| test_cipher.rs:85:75:85:87 | const7.into(...) [element] | test_cipher.rs:85:23:85:61 | ...::new | provenance | MaD:87 Sink:MaD:87 |
| test_cipher.rs:124:9:124:12 | key2 [element] | test_cipher.rs:126:35:126:38 | key2 [element] | provenance | |
| test_cipher.rs:124:25:124:30 | [0; 32] [element] | test_cipher.rs:124:9:124:12 | key2 [element] | provenance | |
@@ -80,10 +87,10 @@ edges
| test_cipher.rs:125:18:125:23 | [0; 12] [element] | test_cipher.rs:125:9:125:14 | nonce2 [element] | provenance | |
| test_cipher.rs:125:19:125:19 | 0 | test_cipher.rs:125:18:125:23 | [0; 12] [element] | provenance | |
| test_cipher.rs:126:34:126:45 | &... [&ref, element] | test_cipher.rs:126:19:126:32 | ...::new | provenance | MaD:90 Sink:MaD:90 Sink:MaD:90 |
-| test_cipher.rs:126:35:126:38 | key2 [element] | test_cipher.rs:126:35:126:45 | key2.into(...) [element] | provenance | MaD:101 |
+| test_cipher.rs:126:35:126:38 | key2 [element] | test_cipher.rs:126:35:126:45 | key2.into(...) [element] | provenance | MaD:102 |
| test_cipher.rs:126:35:126:45 | key2.into(...) [element] | test_cipher.rs:126:34:126:45 | &... [&ref, element] | provenance | |
| test_cipher.rs:127:29:127:42 | &... [&ref, element] | test_cipher.rs:127:21:127:27 | encrypt | provenance | MaD:91 Sink:MaD:91 Sink:MaD:91 |
-| test_cipher.rs:127:30:127:35 | nonce2 [element] | test_cipher.rs:127:30:127:42 | nonce2.into(...) [element] | provenance | MaD:101 |
+| test_cipher.rs:127:30:127:35 | nonce2 [element] | test_cipher.rs:127:30:127:42 | nonce2.into(...) [element] | provenance | MaD:102 |
| test_cipher.rs:127:30:127:42 | nonce2.into(...) [element] | test_cipher.rs:127:29:127:42 | &... [&ref, element] | provenance | |
| test_cipher.rs:129:9:129:18 | key3_array [&ref, element] | test_cipher.rs:130:45:130:54 | key3_array [&ref, element] | provenance | |
| test_cipher.rs:129:32:129:41 | &... [&ref, element] | test_cipher.rs:129:9:129:18 | key3_array [&ref, element] | provenance | |
@@ -99,7 +106,7 @@ edges
| test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | test_cipher.rs:132:19:132:32 | ...::new | provenance | MaD:90 Sink:MaD:90 Sink:MaD:90 Sink:MaD:90 |
| test_cipher.rs:132:35:132:38 | key3 [&ref, element] | test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | provenance | |
| test_cipher.rs:133:29:133:42 | &... [&ref, element] | test_cipher.rs:133:21:133:27 | encrypt | provenance | MaD:91 Sink:MaD:91 Sink:MaD:91 |
-| test_cipher.rs:133:30:133:35 | nonce3 [element] | test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | provenance | MaD:101 |
+| test_cipher.rs:133:30:133:35 | nonce3 [element] | test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | provenance | MaD:102 |
| test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | test_cipher.rs:133:29:133:42 | &... [&ref, element] | provenance | |
nodes
| test_cipher.rs:18:9:18:14 | const1 [&ref, element] | semmle.label | const1 [&ref, element] |
@@ -144,6 +151,13 @@ nodes
| test_cipher.rs:47:30:47:47 | ...::new | semmle.label | ...::new |
| test_cipher.rs:47:49:47:84 | ...::from_slice(...) [&ref, element] | semmle.label | ...::from_slice(...) [&ref, element] |
| test_cipher.rs:47:73:47:83 | const9_conv [&ref, element] | semmle.label | const9_conv [&ref, element] |
+| test_cipher.rs:50:9:50:15 | const10 [element] | semmle.label | const10 [element] |
+| test_cipher.rs:50:37:50:52 | ...::zeroed | semmle.label | ...::zeroed |
+| test_cipher.rs:50:37:50:54 | ...::zeroed(...) [element] | semmle.label | ...::zeroed(...) [element] |
+| test_cipher.rs:51:31:51:48 | ...::new | semmle.label | ...::new |
+| test_cipher.rs:51:50:51:82 | ...::from_slice(...) [&ref, element] | semmle.label | ...::from_slice(...) [&ref, element] |
+| test_cipher.rs:51:74:51:81 | &const10 [&ref, element] | semmle.label | &const10 [&ref, element] |
+| test_cipher.rs:51:75:51:81 | const10 [element] | semmle.label | const10 [element] |
| test_cipher.rs:66:9:66:14 | const2 [&ref, element] | semmle.label | const2 [&ref, element] |
| test_cipher.rs:66:18:66:26 | &... [&ref, element] | semmle.label | &... [&ref, element] |
| test_cipher.rs:66:19:66:26 | [0u8; 32] [element] | semmle.label | [0u8; 32] [element] |
diff --git a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
index d85fffcf58a..cf96cf047b5 100644
--- a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
+++ b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
@@ -47,8 +47,8 @@ fn test_stream_cipher_rabbit(
let mut rabbit_cipher9 = RabbitKeyOnly::new(rabbit::Key::from_slice(const9_conv)); // $ Sink
rabbit_cipher9.apply_keystream(&mut data);
- let const10: [u8;16] = unsafe { std::mem::zeroed() }; // $ MISSING: Alert[rust/hardcoded-crytographic-value]
- let mut rabbit_cipher10 = RabbitKeyOnly::new(rabbit::Key::from_slice(&const10));
+ let const10: [u8;16] = unsafe { std::mem::zeroed() }; // $ Alert[rust/hardcoded-crytographic-value]
+ let mut rabbit_cipher10 = RabbitKeyOnly::new(rabbit::Key::from_slice(&const10)); // $ Sink
rabbit_cipher10.apply_keystream(&mut data);
}
From 95be12ed80f96af4df5d8658037630485e42975b Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Thu, 6 Mar 2025 17:45:34 +0000
Subject: [PATCH 009/534] Rust: Add qhelp and examples.
---
.../CWE-798/HardcodedCryptographicValue.qhelp | 58 +++++++++++++++++++
.../CWE-798/HardcodedCryptographicValueBad.rs | 2 +
.../HardcodedCryptographicValueGood.rs | 2 +
3 files changed, 62 insertions(+)
create mode 100644 rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.qhelp
create mode 100644 rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValueBad.rs
create mode 100644 rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValueGood.rs
diff --git a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.qhelp b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.qhelp
new file mode 100644
index 00000000000..408d4bd002a
--- /dev/null
+++ b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.qhelp
@@ -0,0 +1,58 @@
+
+
+
+
+
+Hardcoded passwords, keys, initialization vectors and salts should not be used for cryptographic operations.
+
+
+ -
+ Attackers can easily recover hardcoded values if they have access to the source code or compiled executable.
+
+ -
+ Some hardcoded values may be easily guessable.
+
+ -
+ Hardcoded values may leave cryptographic operations vulnerable to dictionary attacks, rainbow tables, and other forms of cryptanalysis.
+
+
+
+
+
+
+
+Use randomly generated key material, initialization vectors and salts. Use strong passwords that are not hardcoded in source code.
+
+
+
+
+
+
+The following example shows instantiating a cipher with hardcoded key material, making the encrypted data vulnerable to recovery.
+
+
+
+
+
+In the fixed code below, the key material is randomly generated and not hardcoded, which protects the encrypted data against recovery. A real application would also need a strategy for secure key management after the key has been generated.
+
+
+
+
+
+
+
+
+OWASP: Use of hard-coded password.
+
+
+OWASP: Key Management Cheat Sheet.
+
+
+O'Reilly: Using Salts, Nonces, and Initialization Vectors.
+
+
+
+
diff --git a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValueBad.rs b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValueBad.rs
new file mode 100644
index 00000000000..c1923df1730
--- /dev/null
+++ b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValueBad.rs
@@ -0,0 +1,2 @@
+let key: [u8;32] = [0;32]; // BAD: Using hardcoded keys for encryption
+let cipher = Aes256Gcm::new(&key.into());
diff --git a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValueGood.rs b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValueGood.rs
new file mode 100644
index 00000000000..06dc1af836d
--- /dev/null
+++ b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValueGood.rs
@@ -0,0 +1,2 @@
+let key = Aes256Gcm::generate_key(aes_gcm::aead::OsRng); // GOOD: Using randomly generated keys for encryption
+let cipher = Aes256Gcm::new(&key);
From e564c410439eb8898ec829ca6487883ca8122bc5 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Thu, 6 Mar 2025 18:36:55 +0000
Subject: [PATCH 010/534] Rust: Compute security-severity tag.
---
.../src/queries/security/CWE-798/HardcodedCryptographicValue.ql | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
index 441c22f679a..49e8b0cf342 100644
--- a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
+++ b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
@@ -4,7 +4,7 @@
* vectors is not secure.
* @kind path-problem
* @problem.severity warning
- * @security-severity TODO
+ * @security-severity 9.8
* @precision high
* @id rust/hardcoded-crytographic-value
* @tags security
From 952e417d13b6a18f01386e3d7773ebad76c5b8a3 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Thu, 6 Mar 2025 18:46:37 +0000
Subject: [PATCH 011/534] Rust: Tweak some wording.
---
.../rust/security/HardcodedCryptographicValueExtensions.qll | 2 +-
.../security/CWE-798/HardcodedCryptographicValue.qhelp | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll b/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
index 4d6210cb97b..32f64051fcb 100644
--- a/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
+++ b/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
@@ -80,7 +80,7 @@ module HardcodedCryptographicValue {
}
/**
- * A sink for hardcoded cryptographic value from model data.
+ * An externally modeled sink for hardcoded cryptographic value vulnerabilities.
*/
private class ModelsAsDataSinks extends Sink {
CryptographicValueKind kind;
diff --git a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.qhelp b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.qhelp
index 408d4bd002a..b44a98013c8 100644
--- a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.qhelp
+++ b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.qhelp
@@ -12,10 +12,10 @@ Hardcoded passwords, keys, initialization vectors and salts should not be used f
Attackers can easily recover hardcoded values if they have access to the source code or compiled executable.
- Some hardcoded values may be easily guessable.
+ Some hardcoded values are easily guessable.
- Hardcoded values may leave cryptographic operations vulnerable to dictionary attacks, rainbow tables, and other forms of cryptanalysis.
+ Use of hardcoded values may leave cryptographic operations vulnerable to dictionary attacks, rainbow tables, and other forms of cryptanalysis.
@@ -23,7 +23,7 @@ Hardcoded passwords, keys, initialization vectors and salts should not be used f
-Use randomly generated key material, initialization vectors and salts. Use strong passwords that are not hardcoded in source code.
+Use randomly generated key material, initialization vectors and salts. Use strong passwords that are not hardcoded.
From 9af2d0218b777520f33f0a836bfc0efbdc172430 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Thu, 6 Mar 2025 18:48:26 +0000
Subject: [PATCH 012/534] Rust: Add the new sinks to stats.
---
rust/ql/src/queries/summary/Stats.qll | 3 +++
rust/ql/test/query-tests/diagnostics/SummaryStats.expected | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/rust/ql/src/queries/summary/Stats.qll b/rust/ql/src/queries/summary/Stats.qll
index 4054b0bc132..bc6e38ba67a 100644
--- a/rust/ql/src/queries/summary/Stats.qll
+++ b/rust/ql/src/queries/summary/Stats.qll
@@ -11,6 +11,7 @@ private import codeql.rust.controlflow.internal.CfgConsistency as CfgConsistency
private import codeql.rust.dataflow.internal.DataFlowConsistency as DataFlowConsistency
private import codeql.rust.security.SqlInjectionExtensions
private import codeql.rust.security.CleartextLoggingExtensions
+private import codeql.rust.security.HardcodedCryptographicValueExtensions
/**
* Gets a count of the total number of lines of code in the database.
@@ -62,6 +63,8 @@ string getAQuerySinkKind(DataFlow::Node n) {
n instanceof SqlInjection::Sink and result = "SqlInjection"
or
n instanceof CleartextLogging::Sink and result = "CleartextLogging"
+ or
+ n instanceof HardcodedCryptographicValue::Sink and result = "HardcodedCryptographicValue"
}
/**
diff --git a/rust/ql/test/query-tests/diagnostics/SummaryStats.expected b/rust/ql/test/query-tests/diagnostics/SummaryStats.expected
index 7abbbba7c1b..c87c80da8c7 100644
--- a/rust/ql/test/query-tests/diagnostics/SummaryStats.expected
+++ b/rust/ql/test/query-tests/diagnostics/SummaryStats.expected
@@ -14,7 +14,7 @@
| Macro calls - resolved | 8 |
| Macro calls - total | 9 |
| Macro calls - unresolved | 1 |
-| Taint edges - number of edges | 1471 |
+| Taint edges - number of edges | 1475 |
| Taint reach - nodes tainted | 0 |
| Taint reach - per million nodes | 0 |
| Taint sinks - cryptographic operations | 0 |
From 42e7d1e983465b4da3ced5805e21c51efec84aaa Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Thu, 6 Mar 2025 19:09:01 +0000
Subject: [PATCH 013/534] Rust: Fix typo.
---
.../CWE-798/HardcodedCryptographicValue.ql | 2 +-
.../security/CWE-798/test_cipher.rs | 36 +++++++++----------
2 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
index 49e8b0cf342..3fb9d4d74a2 100644
--- a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
+++ b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
@@ -6,7 +6,7 @@
* @problem.severity warning
* @security-severity 9.8
* @precision high
- * @id rust/hardcoded-crytographic-value
+ * @id rust/hardcoded-cryptographic-value
* @tags security
* external/cwe/cwe-259
* external/cwe/cwe-321
diff --git a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
index cf96cf047b5..7a5ef0572fd 100644
--- a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
+++ b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
@@ -15,18 +15,18 @@ fn test_stream_cipher_rabbit(
let mut rabbit_cipher1 = RabbitKeyOnly::new(rabbit::Key::from_slice(key));
rabbit_cipher1.apply_keystream(&mut data);
- let const1: &[u8;16] = &[0u8;16]; // $ Alert[rust/hardcoded-crytographic-value]
+ let const1: &[u8;16] = &[0u8;16]; // $ Alert[rust/hardcoded-cryptographic-value]
let mut rabbit_cipher2 = RabbitKeyOnly::new(rabbit::Key::from_slice(const1)); // $ Sink
rabbit_cipher2.apply_keystream(&mut data);
let mut rabbit_cipher3 = Rabbit::new(rabbit::Key::from_slice(key), rabbit::Iv::from_slice(iv));
rabbit_cipher3.apply_keystream(&mut data);
- let const4: &[u8;16] = &[0u8;16]; // $ Alert[rust/hardcoded-crytographic-value]
+ let const4: &[u8;16] = &[0u8;16]; // $ Alert[rust/hardcoded-cryptographic-value]
let mut rabbit_cipher4 = Rabbit::new(rabbit::Key::from_slice(const4), rabbit::Iv::from_slice(iv)); // $ Sink
rabbit_cipher4.apply_keystream(&mut data);
- let const5: &[u8;16] = &[0u8;16]; // $ Alert[rust/hardcoded-crytographic-value]
+ let const5: &[u8;16] = &[0u8;16]; // $ Alert[rust/hardcoded-cryptographic-value]
let mut rabbit_cipher5 = Rabbit::new(rabbit::Key::from_slice(key), rabbit::Iv::from_slice(const5)); // $ Sink
rabbit_cipher5.apply_keystream(&mut data);
@@ -34,20 +34,20 @@ fn test_stream_cipher_rabbit(
let const6: &[u8;16] = &[0u8;16]; // (unused, so good)
- let const7: [u8;16] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // $ Alert[rust/hardcoded-crytographic-value]
+ let const7: [u8;16] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // $ Alert[rust/hardcoded-cryptographic-value]
let mut rabbit_cipher7 = RabbitKeyOnly::new(rabbit::Key::from_slice(&const7)); // $ Sink
rabbit_cipher7.apply_keystream(&mut data);
- let const8: &[u8;16] = &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // $ Alert[rust/hardcoded-crytographic-value]
+ let const8: &[u8;16] = &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // $ Alert[rust/hardcoded-cryptographic-value]
let mut rabbit_cipher8 = RabbitKeyOnly::new(rabbit::Key::from_slice(const8)); // $ Sink
rabbit_cipher8.apply_keystream(&mut data);
- let const9: [u16;8] = [0, 0, 0, 0, 0, 0, 0, 0]; // $ Alert[rust/hardcoded-crytographic-value]
+ let const9: [u16;8] = [0, 0, 0, 0, 0, 0, 0, 0]; // $ Alert[rust/hardcoded-cryptographic-value]
let const9_conv = unsafe { const9.align_to::().1 }; // convert [u16;8] -> [u8;8]
let mut rabbit_cipher9 = RabbitKeyOnly::new(rabbit::Key::from_slice(const9_conv)); // $ Sink
rabbit_cipher9.apply_keystream(&mut data);
- let const10: [u8;16] = unsafe { std::mem::zeroed() }; // $ Alert[rust/hardcoded-crytographic-value]
+ let const10: [u8;16] = unsafe { std::mem::zeroed() }; // $ Alert[rust/hardcoded-cryptographic-value]
let mut rabbit_cipher10 = RabbitKeyOnly::new(rabbit::Key::from_slice(&const10)); // $ Sink
rabbit_cipher10.apply_keystream(&mut data);
}
@@ -63,25 +63,25 @@ fn test_block_cipher_aes(
let aes_cipher1 = Aes256::new(key256.into());
aes_cipher1.encrypt_block(block128.into());
- let const2 = &[0u8;32]; // $ Alert[rust/hardcoded-crytographic-value]
+ let const2 = &[0u8;32]; // $ Alert[rust/hardcoded-cryptographic-value]
let aes_cipher2 = Aes256::new(const2.into()); // $ Sink
aes_cipher2.encrypt_block(block128.into());
let aes_cipher3 = Aes256::new_from_slice(key256).unwrap();
aes_cipher3.encrypt_block(block128.into());
- let const2 = &[0u8;32]; // $ Alert[rust/hardcoded-crytographic-value]
+ let const2 = &[0u8;32]; // $ Alert[rust/hardcoded-cryptographic-value]
let aes_cipher4 = Aes256::new_from_slice(const2).unwrap(); // $ Sink
aes_cipher4.encrypt_block(block128.into());
let aes_cipher5 = cfb_mode::Encryptor::::new(key.into(), iv.into());
_ = aes_cipher5.encrypt_b2b(input, output).unwrap();
- let const6 = &[0u8;32]; // $ Alert[rust/hardcoded-crytographic-value]
+ let const6 = &[0u8;32]; // $ Alert[rust/hardcoded-cryptographic-value]
let aes_cipher6 = cfb_mode::Encryptor::::new(const6.into(), iv.into()); // $ Sink
_ = aes_cipher6.encrypt_b2b(input, output).unwrap();
- let const7 = &[0u8; 16]; // $ Alert[rust/hardcoded-crytographic-value]
+ let const7 = &[0u8; 16]; // $ Alert[rust/hardcoded-cryptographic-value]
let aes_cipher7 = cfb_mode::Encryptor::::new(key.into(), const7.into()); // $ Sink
_ = aes_cipher7.encrypt_b2b(input, output).unwrap();
@@ -91,18 +91,18 @@ fn test_block_cipher_aes(
let aes_cipher8 = cfb_mode::Encryptor::::new(key8.into(), iv.into());
_ = aes_cipher8.encrypt_b2b(input, output).unwrap();
- let key9: &[u8] = "1234567890123456".as_bytes(); // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ let key9: &[u8] = "1234567890123456".as_bytes(); // $ MISSING: Alert[rust/hardcoded-cryptographic-value]
let aes_cipher9 = cfb_mode::Encryptor::::new(key9.into(), iv.into());
_ = aes_cipher9.encrypt_b2b(input, output).unwrap();
let key10: [u8; 32] = match base64::engine::general_purpose::STANDARD.decode(key_str) {
Ok(x) => x.try_into().unwrap(),
- Err(_) => "1234567890123456".as_bytes().try_into().unwrap() // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ Err(_) => "1234567890123456".as_bytes().try_into().unwrap() // $ MISSING: Alert[rust/hardcoded-cryptographic-value]
};
let aes_cipher10 = Aes256::new(&key10.into());
aes_cipher10.encrypt_block(block128.into());
- if let Ok(const11) = base64::engine::general_purpose::STANDARD.decode("1234567890123456") { // $ MISSING: Alert[rust/hardcoded-crytographic-value]
+ if let Ok(const11) = base64::engine::general_purpose::STANDARD.decode("1234567890123456") { // $ MISSING: Alert[rust/hardcoded-cryptographic-value]
let key11: [u8; 32] = const11.try_into().unwrap();
let aes_cipher11 = Aes256::new(&key11.into());
aes_cipher11.encrypt_block(block128.into());
@@ -121,14 +121,14 @@ fn test_aes_gcm(
let cipher1 = Aes256Gcm::new(&key1);
let _ = cipher1.encrypt(&nonce1, b"plaintext".as_ref()).unwrap();
- let key2: [u8;32] = [0;32]; // $ Alert[rust/hardcoded-crytographic-value]
- let nonce2 = [0;12]; // $ Alert[rust/hardcoded-crytographic-value]
+ let key2: [u8;32] = [0;32]; // $ Alert[rust/hardcoded-cryptographic-value]
+ let nonce2 = [0;12]; // $ Alert[rust/hardcoded-cryptographic-value]
let cipher2 = Aes256Gcm::new(&key2.into()); // $ Sink
let _ = cipher2.encrypt(&nonce2.into(), b"plaintext".as_ref()).unwrap(); // $ Sink
- let key3_array: &[u8;32] = &[0xff;32]; // $ Alert[rust/hardcoded-crytographic-value]
+ let key3_array: &[u8;32] = &[0xff;32]; // $ Alert[rust/hardcoded-cryptographic-value]
let key3 = Key::::from_slice(key3_array);
- let nonce3: [u8;12] = [0xff;12]; // $ Alert[rust/hardcoded-crytographic-value]
+ let nonce3: [u8;12] = [0xff;12]; // $ Alert[rust/hardcoded-cryptographic-value]
let cipher3 = Aes256Gcm::new(&key3); // $ Sink
let _ = cipher3.encrypt(&nonce3.into(), b"plaintext".as_ref()).unwrap(); // $ Sink
}
From 19416a9ee3038a6c3d4bb62ce25af6c7d83c5972 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Fri, 7 Mar 2025 15:43:34 +0000
Subject: [PATCH 014/534] Rust: Correct test results.
---
.../diagnostics/SummaryStats.expected | 6 +--
.../HardcodedCryptographicValue.expected | 39 ++++++++-----------
2 files changed, 18 insertions(+), 27 deletions(-)
diff --git a/rust/ql/test/query-tests/diagnostics/SummaryStats.expected b/rust/ql/test/query-tests/diagnostics/SummaryStats.expected
index b9a96cdecfd..972c5f26177 100644
--- a/rust/ql/test/query-tests/diagnostics/SummaryStats.expected
+++ b/rust/ql/test/query-tests/diagnostics/SummaryStats.expected
@@ -14,11 +14,7 @@
| Macro calls - resolved | 8 |
| Macro calls - total | 9 |
| Macro calls - unresolved | 1 |
-<<<<<<< HEAD
-| Taint edges - number of edges | 1475 |
-=======
-| Taint edges - number of edges | 1670 |
->>>>>>> main
+| Taint edges - number of edges | 1674 |
| Taint reach - nodes tainted | 0 |
| Taint reach - per million nodes | 0 |
| Taint sinks - cryptographic operations | 0 |
diff --git a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
index a09f89d2127..a8ce502c403 100644
--- a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
+++ b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
@@ -19,49 +19,49 @@ edges
| test_cipher.rs:18:28:18:36 | &... [&ref, element] | test_cipher.rs:18:9:18:14 | const1 [&ref, element] | provenance | |
| test_cipher.rs:18:29:18:36 | [0u8; 16] [element] | test_cipher.rs:18:28:18:36 | &... [&ref, element] | provenance | |
| test_cipher.rs:18:30:18:32 | 0u8 | test_cipher.rs:18:29:18:36 | [0u8; 16] [element] | provenance | |
-| test_cipher.rs:19:49:19:79 | ...::from_slice(...) [&ref, element] | test_cipher.rs:19:30:19:47 | ...::new | provenance | MaD:58 Sink:MaD:58 Sink:MaD:58 |
+| test_cipher.rs:19:49:19:79 | ...::from_slice(...) [&ref, element] | test_cipher.rs:19:30:19:47 | ...::new | provenance | MaD:60 Sink:MaD:60 Sink:MaD:60 |
| test_cipher.rs:19:73:19:78 | const1 [&ref, element] | test_cipher.rs:19:49:19:79 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
| test_cipher.rs:25:9:25:14 | const4 [&ref, element] | test_cipher.rs:26:66:26:71 | const4 [&ref, element] | provenance | |
| test_cipher.rs:25:28:25:36 | &... [&ref, element] | test_cipher.rs:25:9:25:14 | const4 [&ref, element] | provenance | |
| test_cipher.rs:25:29:25:36 | [0u8; 16] [element] | test_cipher.rs:25:28:25:36 | &... [&ref, element] | provenance | |
| test_cipher.rs:25:30:25:32 | 0u8 | test_cipher.rs:25:29:25:36 | [0u8; 16] [element] | provenance | |
-| test_cipher.rs:26:42:26:72 | ...::from_slice(...) [&ref, element] | test_cipher.rs:26:30:26:40 | ...::new | provenance | MaD:82 Sink:MaD:82 Sink:MaD:82 |
+| test_cipher.rs:26:42:26:72 | ...::from_slice(...) [&ref, element] | test_cipher.rs:26:30:26:40 | ...::new | provenance | MaD:60 Sink:MaD:60 Sink:MaD:60 |
| test_cipher.rs:26:66:26:71 | const4 [&ref, element] | test_cipher.rs:26:42:26:72 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
| test_cipher.rs:29:9:29:14 | const5 [&ref, element] | test_cipher.rs:30:95:30:100 | const5 [&ref, element] | provenance | |
| test_cipher.rs:29:28:29:36 | &... [&ref, element] | test_cipher.rs:29:9:29:14 | const5 [&ref, element] | provenance | |
| test_cipher.rs:29:29:29:36 | [0u8; 16] [element] | test_cipher.rs:29:28:29:36 | &... [&ref, element] | provenance | |
| test_cipher.rs:29:30:29:32 | 0u8 | test_cipher.rs:29:29:29:36 | [0u8; 16] [element] | provenance | |
-| test_cipher.rs:30:72:30:101 | ...::from_slice(...) [&ref, element] | test_cipher.rs:30:30:30:40 | ...::new | provenance | MaD:83 Sink:MaD:83 Sink:MaD:83 |
+| test_cipher.rs:30:72:30:101 | ...::from_slice(...) [&ref, element] | test_cipher.rs:30:30:30:40 | ...::new | provenance | MaD:61 Sink:MaD:61 Sink:MaD:61 |
| test_cipher.rs:30:95:30:100 | const5 [&ref, element] | test_cipher.rs:30:72:30:101 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
| test_cipher.rs:37:9:37:14 | const7 | test_cipher.rs:38:74:38:79 | const7 | provenance | |
| test_cipher.rs:37:27:37:74 | [...] | test_cipher.rs:37:9:37:14 | const7 | provenance | |
-| test_cipher.rs:38:49:38:80 | ...::from_slice(...) [&ref] | test_cipher.rs:38:30:38:47 | ...::new | provenance | MaD:58 Sink:MaD:58 |
+| test_cipher.rs:38:49:38:80 | ...::from_slice(...) [&ref] | test_cipher.rs:38:30:38:47 | ...::new | provenance | MaD:60 Sink:MaD:60 |
| test_cipher.rs:38:73:38:79 | &const7 [&ref] | test_cipher.rs:38:49:38:80 | ...::from_slice(...) [&ref] | provenance | MaD:0 |
| test_cipher.rs:38:74:38:79 | const7 | test_cipher.rs:38:73:38:79 | &const7 [&ref] | provenance | |
| test_cipher.rs:41:9:41:14 | const8 [&ref] | test_cipher.rs:42:73:42:78 | const8 [&ref] | provenance | |
| test_cipher.rs:41:28:41:76 | &... [&ref] | test_cipher.rs:41:9:41:14 | const8 [&ref] | provenance | |
| test_cipher.rs:41:29:41:76 | [...] | test_cipher.rs:41:28:41:76 | &... [&ref] | provenance | |
-| test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref] | test_cipher.rs:42:30:42:47 | ...::new | provenance | MaD:58 Sink:MaD:58 |
+| test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref] | test_cipher.rs:42:30:42:47 | ...::new | provenance | MaD:60 Sink:MaD:60 |
| test_cipher.rs:42:73:42:78 | const8 [&ref] | test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref] | provenance | MaD:0 |
-| test_cipher.rs:45:9:45:14 | const9 | test_cipher.rs:46:32:46:37 | const9 | provenance | |
+| test_cipher.rs:45:9:45:14 | const9 | test_cipher.rs:46:32:46:54 | const9.align_to(...) [tuple.1, &ref, element] | provenance | MaD:104 |
| test_cipher.rs:45:27:45:50 | [...] | test_cipher.rs:45:9:45:14 | const9 | provenance | |
| test_cipher.rs:46:9:46:19 | const9_conv [&ref, element] | test_cipher.rs:47:73:47:83 | const9_conv [&ref, element] | provenance | |
-| test_cipher.rs:46:32:46:37 | const9 | test_cipher.rs:46:32:46:54 | const9.align_to(...) [tuple.1, &ref, element] | provenance | MaD:104 |
| test_cipher.rs:46:32:46:54 | const9.align_to(...) [tuple.1, &ref, element] | test_cipher.rs:46:32:46:56 | ... .1 [&ref, element] | provenance | |
| test_cipher.rs:46:32:46:56 | ... .1 [&ref, element] | test_cipher.rs:46:9:46:19 | const9_conv [&ref, element] | provenance | |
-| test_cipher.rs:47:49:47:84 | ...::from_slice(...) [&ref, element] | test_cipher.rs:47:30:47:47 | ...::new | provenance | MaD:58 Sink:MaD:58 Sink:MaD:58 |
+| test_cipher.rs:47:49:47:84 | ...::from_slice(...) [&ref, element] | test_cipher.rs:47:30:47:47 | ...::new | provenance | MaD:60 Sink:MaD:60 Sink:MaD:60 |
| test_cipher.rs:47:73:47:83 | const9_conv [&ref, element] | test_cipher.rs:47:49:47:84 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
| test_cipher.rs:50:9:50:15 | const10 [element] | test_cipher.rs:51:75:51:81 | const10 [element] | provenance | |
| test_cipher.rs:50:37:50:52 | ...::zeroed | test_cipher.rs:50:37:50:54 | ...::zeroed(...) [element] | provenance | Src:MaD:101 |
| test_cipher.rs:50:37:50:54 | ...::zeroed(...) [element] | test_cipher.rs:50:9:50:15 | const10 [element] | provenance | |
-| test_cipher.rs:51:50:51:82 | ...::from_slice(...) [&ref, element] | test_cipher.rs:51:31:51:48 | ...::new | provenance | MaD:58 Sink:MaD:58 Sink:MaD:58 |
+| test_cipher.rs:51:50:51:82 | ...::from_slice(...) [&ref, element] | test_cipher.rs:51:31:51:48 | ...::new | provenance | MaD:60 Sink:MaD:60 Sink:MaD:60 |
| test_cipher.rs:51:74:51:81 | &const10 [&ref, element] | test_cipher.rs:51:50:51:82 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
| test_cipher.rs:51:75:51:81 | const10 [element] | test_cipher.rs:51:74:51:81 | &const10 [&ref, element] | provenance | |
| test_cipher.rs:66:9:66:14 | const2 [&ref, element] | test_cipher.rs:67:35:67:40 | const2 [&ref, element] | provenance | |
+| test_cipher.rs:66:9:66:14 | const2 [&ref, element] | test_cipher.rs:67:35:67:47 | const2.into(...) [element] | provenance | MaD:103 |
| test_cipher.rs:66:18:66:26 | &... [&ref, element] | test_cipher.rs:66:9:66:14 | const2 [&ref, element] | provenance | |
| test_cipher.rs:66:19:66:26 | [0u8; 32] [element] | test_cipher.rs:66:18:66:26 | &... [&ref, element] | provenance | |
| test_cipher.rs:66:20:66:22 | 0u8 | test_cipher.rs:66:19:66:26 | [0u8; 32] [element] | provenance | |
-| test_cipher.rs:67:35:67:40 | const2 [&ref, element] | test_cipher.rs:67:35:67:47 | const2.into(...) [element] | provenance | MaD:103 |
+| test_cipher.rs:67:35:67:40 | const2 [&ref, element] | test_cipher.rs:67:35:67:47 | const2.into(...) [element] | provenance | MaD:102 |
| test_cipher.rs:67:35:67:47 | const2.into(...) [element] | test_cipher.rs:67:23:67:33 | ...::new | provenance | MaD:76 Sink:MaD:76 |
| test_cipher.rs:73:9:73:14 | const2 [&ref, element] | test_cipher.rs:74:46:74:51 | const2 [&ref, element] | provenance | |
| test_cipher.rs:73:18:73:26 | &... [&ref, element] | test_cipher.rs:73:9:73:14 | const2 [&ref, element] | provenance | |
@@ -69,28 +69,28 @@ edges
| test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:73:19:73:26 | [0u8; 32] [element] | provenance | |
| test_cipher.rs:74:46:74:51 | const2 [&ref, element] | test_cipher.rs:74:23:74:44 | ...::new_from_slice | provenance | MaD:84 Sink:MaD:84 Sink:MaD:84 |
| test_cipher.rs:80:9:80:14 | const6 [&ref, element] | test_cipher.rs:81:63:81:68 | const6 [&ref, element] | provenance | |
+| test_cipher.rs:80:9:80:14 | const6 [&ref, element] | test_cipher.rs:81:63:81:75 | const6.into(...) [element] | provenance | MaD:103 |
| test_cipher.rs:80:18:80:26 | &... [&ref, element] | test_cipher.rs:80:9:80:14 | const6 [&ref, element] | provenance | |
| test_cipher.rs:80:19:80:26 | [0u8; 32] [element] | test_cipher.rs:80:18:80:26 | &... [&ref, element] | provenance | |
| test_cipher.rs:80:20:80:22 | 0u8 | test_cipher.rs:80:19:80:26 | [0u8; 32] [element] | provenance | |
-| test_cipher.rs:81:63:81:68 | const6 [&ref, element] | test_cipher.rs:81:63:81:75 | const6.into(...) [element] | provenance | MaD:103 |
+| test_cipher.rs:81:63:81:68 | const6 [&ref, element] | test_cipher.rs:81:63:81:75 | const6.into(...) [element] | provenance | MaD:102 |
| test_cipher.rs:81:63:81:75 | const6.into(...) [element] | test_cipher.rs:81:23:81:61 | ...::new | provenance | MaD:86 Sink:MaD:86 |
| test_cipher.rs:84:9:84:14 | const7 [&ref, element] | test_cipher.rs:85:75:85:80 | const7 [&ref, element] | provenance | |
+| test_cipher.rs:84:9:84:14 | const7 [&ref, element] | test_cipher.rs:85:75:85:87 | const7.into(...) [element] | provenance | MaD:103 |
| test_cipher.rs:84:18:84:27 | &... [&ref, element] | test_cipher.rs:84:9:84:14 | const7 [&ref, element] | provenance | |
| test_cipher.rs:84:19:84:27 | [0u8; 16] [element] | test_cipher.rs:84:18:84:27 | &... [&ref, element] | provenance | |
| test_cipher.rs:84:20:84:22 | 0u8 | test_cipher.rs:84:19:84:27 | [0u8; 16] [element] | provenance | |
-| test_cipher.rs:85:75:85:80 | const7 [&ref, element] | test_cipher.rs:85:75:85:87 | const7.into(...) [element] | provenance | MaD:103 |
+| test_cipher.rs:85:75:85:80 | const7 [&ref, element] | test_cipher.rs:85:75:85:87 | const7.into(...) [element] | provenance | MaD:102 |
| test_cipher.rs:85:75:85:87 | const7.into(...) [element] | test_cipher.rs:85:23:85:61 | ...::new | provenance | MaD:87 Sink:MaD:87 |
-| test_cipher.rs:124:9:124:12 | key2 [element] | test_cipher.rs:126:35:126:38 | key2 [element] | provenance | |
+| test_cipher.rs:124:9:124:12 | key2 [element] | test_cipher.rs:126:35:126:45 | key2.into(...) [element] | provenance | MaD:102 |
| test_cipher.rs:124:25:124:30 | [0; 32] [element] | test_cipher.rs:124:9:124:12 | key2 [element] | provenance | |
| test_cipher.rs:124:26:124:26 | 0 | test_cipher.rs:124:25:124:30 | [0; 32] [element] | provenance | |
-| test_cipher.rs:125:9:125:14 | nonce2 [element] | test_cipher.rs:127:30:127:35 | nonce2 [element] | provenance | |
+| test_cipher.rs:125:9:125:14 | nonce2 [element] | test_cipher.rs:127:30:127:42 | nonce2.into(...) [element] | provenance | MaD:102 |
| test_cipher.rs:125:18:125:23 | [0; 12] [element] | test_cipher.rs:125:9:125:14 | nonce2 [element] | provenance | |
| test_cipher.rs:125:19:125:19 | 0 | test_cipher.rs:125:18:125:23 | [0; 12] [element] | provenance | |
| test_cipher.rs:126:34:126:45 | &... [&ref, element] | test_cipher.rs:126:19:126:32 | ...::new | provenance | MaD:90 Sink:MaD:90 Sink:MaD:90 |
-| test_cipher.rs:126:35:126:38 | key2 [element] | test_cipher.rs:126:35:126:45 | key2.into(...) [element] | provenance | MaD:102 |
| test_cipher.rs:126:35:126:45 | key2.into(...) [element] | test_cipher.rs:126:34:126:45 | &... [&ref, element] | provenance | |
| test_cipher.rs:127:29:127:42 | &... [&ref, element] | test_cipher.rs:127:21:127:27 | encrypt | provenance | MaD:91 Sink:MaD:91 Sink:MaD:91 |
-| test_cipher.rs:127:30:127:35 | nonce2 [element] | test_cipher.rs:127:30:127:42 | nonce2.into(...) [element] | provenance | MaD:102 |
| test_cipher.rs:127:30:127:42 | nonce2.into(...) [element] | test_cipher.rs:127:29:127:42 | &... [&ref, element] | provenance | |
| test_cipher.rs:129:9:129:18 | key3_array [&ref, element] | test_cipher.rs:130:45:130:54 | key3_array [&ref, element] | provenance | |
| test_cipher.rs:129:32:129:41 | &... [&ref, element] | test_cipher.rs:129:9:129:18 | key3_array [&ref, element] | provenance | |
@@ -99,14 +99,13 @@ edges
| test_cipher.rs:130:9:130:12 | key3 [&ref, element] | test_cipher.rs:132:35:132:38 | key3 [&ref, element] | provenance | |
| test_cipher.rs:130:16:130:55 | ...::from_slice(...) [&ref, element] | test_cipher.rs:130:9:130:12 | key3 [&ref, element] | provenance | |
| test_cipher.rs:130:45:130:54 | key3_array [&ref, element] | test_cipher.rs:130:16:130:55 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
-| test_cipher.rs:131:9:131:14 | nonce3 [element] | test_cipher.rs:133:30:133:35 | nonce3 [element] | provenance | |
+| test_cipher.rs:131:9:131:14 | nonce3 [element] | test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | provenance | MaD:102 |
| test_cipher.rs:131:27:131:35 | [0xff; 12] [element] | test_cipher.rs:131:9:131:14 | nonce3 [element] | provenance | |
| test_cipher.rs:131:28:131:31 | 0xff | test_cipher.rs:131:27:131:35 | [0xff; 12] [element] | provenance | |
| test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | test_cipher.rs:132:19:132:32 | ...::new | provenance | MaD:90 Sink:MaD:90 Sink:MaD:90 |
| test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | test_cipher.rs:132:19:132:32 | ...::new | provenance | MaD:90 Sink:MaD:90 Sink:MaD:90 Sink:MaD:90 |
| test_cipher.rs:132:35:132:38 | key3 [&ref, element] | test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | provenance | |
| test_cipher.rs:133:29:133:42 | &... [&ref, element] | test_cipher.rs:133:21:133:27 | encrypt | provenance | MaD:91 Sink:MaD:91 Sink:MaD:91 |
-| test_cipher.rs:133:30:133:35 | nonce3 [element] | test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | provenance | MaD:102 |
| test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | test_cipher.rs:133:29:133:42 | &... [&ref, element] | provenance | |
nodes
| test_cipher.rs:18:9:18:14 | const1 [&ref, element] | semmle.label | const1 [&ref, element] |
@@ -145,7 +144,6 @@ nodes
| test_cipher.rs:45:9:45:14 | const9 | semmle.label | const9 |
| test_cipher.rs:45:27:45:50 | [...] | semmle.label | [...] |
| test_cipher.rs:46:9:46:19 | const9_conv [&ref, element] | semmle.label | const9_conv [&ref, element] |
-| test_cipher.rs:46:32:46:37 | const9 | semmle.label | const9 |
| test_cipher.rs:46:32:46:54 | const9.align_to(...) [tuple.1, &ref, element] | semmle.label | const9.align_to(...) [tuple.1, &ref, element] |
| test_cipher.rs:46:32:46:56 | ... .1 [&ref, element] | semmle.label | ... .1 [&ref, element] |
| test_cipher.rs:47:30:47:47 | ...::new | semmle.label | ...::new |
@@ -193,11 +191,9 @@ nodes
| test_cipher.rs:125:19:125:19 | 0 | semmle.label | 0 |
| test_cipher.rs:126:19:126:32 | ...::new | semmle.label | ...::new |
| test_cipher.rs:126:34:126:45 | &... [&ref, element] | semmle.label | &... [&ref, element] |
-| test_cipher.rs:126:35:126:38 | key2 [element] | semmle.label | key2 [element] |
| test_cipher.rs:126:35:126:45 | key2.into(...) [element] | semmle.label | key2.into(...) [element] |
| test_cipher.rs:127:21:127:27 | encrypt | semmle.label | encrypt |
| test_cipher.rs:127:29:127:42 | &... [&ref, element] | semmle.label | &... [&ref, element] |
-| test_cipher.rs:127:30:127:35 | nonce2 [element] | semmle.label | nonce2 [element] |
| test_cipher.rs:127:30:127:42 | nonce2.into(...) [element] | semmle.label | nonce2.into(...) [element] |
| test_cipher.rs:129:9:129:18 | key3_array [&ref, element] | semmle.label | key3_array [&ref, element] |
| test_cipher.rs:129:32:129:41 | &... [&ref, element] | semmle.label | &... [&ref, element] |
@@ -214,6 +210,5 @@ nodes
| test_cipher.rs:132:35:132:38 | key3 [&ref, element] | semmle.label | key3 [&ref, element] |
| test_cipher.rs:133:21:133:27 | encrypt | semmle.label | encrypt |
| test_cipher.rs:133:29:133:42 | &... [&ref, element] | semmle.label | &... [&ref, element] |
-| test_cipher.rs:133:30:133:35 | nonce3 [element] | semmle.label | nonce3 [element] |
| test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | semmle.label | nonce3.into(...) [element] |
subpaths
From c63c1be11ca844b686cb71c16cb0e45f668d6450 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Fri, 7 Mar 2025 16:12:31 +0000
Subject: [PATCH 015/534] Rust: Accept integration test .expected changes.
---
rust/ql/integration-tests/hello-project/summary.expected | 2 +-
.../ql/integration-tests/hello-workspace/summary.cargo.expected | 2 +-
.../hello-workspace/summary.rust-project.expected | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/rust/ql/integration-tests/hello-project/summary.expected b/rust/ql/integration-tests/hello-project/summary.expected
index 2ffb1f4e34f..68ee47035bc 100644
--- a/rust/ql/integration-tests/hello-project/summary.expected
+++ b/rust/ql/integration-tests/hello-project/summary.expected
@@ -14,7 +14,7 @@
| Macro calls - resolved | 2 |
| Macro calls - total | 2 |
| Macro calls - unresolved | 0 |
-| Taint edges - number of edges | 1670 |
+| Taint edges - number of edges | 1674 |
| Taint reach - nodes tainted | 0 |
| Taint reach - per million nodes | 0 |
| Taint sinks - cryptographic operations | 0 |
diff --git a/rust/ql/integration-tests/hello-workspace/summary.cargo.expected b/rust/ql/integration-tests/hello-workspace/summary.cargo.expected
index d08ce1a4116..caf7b2b8cd9 100644
--- a/rust/ql/integration-tests/hello-workspace/summary.cargo.expected
+++ b/rust/ql/integration-tests/hello-workspace/summary.cargo.expected
@@ -14,7 +14,7 @@
| Macro calls - resolved | 2 |
| Macro calls - total | 2 |
| Macro calls - unresolved | 0 |
-| Taint edges - number of edges | 1670 |
+| Taint edges - number of edges | 1674 |
| Taint reach - nodes tainted | 0 |
| Taint reach - per million nodes | 0 |
| Taint sinks - cryptographic operations | 0 |
diff --git a/rust/ql/integration-tests/hello-workspace/summary.rust-project.expected b/rust/ql/integration-tests/hello-workspace/summary.rust-project.expected
index d08ce1a4116..caf7b2b8cd9 100644
--- a/rust/ql/integration-tests/hello-workspace/summary.rust-project.expected
+++ b/rust/ql/integration-tests/hello-workspace/summary.rust-project.expected
@@ -14,7 +14,7 @@
| Macro calls - resolved | 2 |
| Macro calls - total | 2 |
| Macro calls - unresolved | 0 |
-| Taint edges - number of edges | 1670 |
+| Taint edges - number of edges | 1674 |
| Taint reach - nodes tainted | 0 |
| Taint reach - per million nodes | 0 |
| Taint sinks - cryptographic operations | 0 |
From 3dc35f1fabe6435eb65a38b5aa21f4326a3563d7 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Fri, 7 Mar 2025 17:02:26 +0000
Subject: [PATCH 016/534] Rust: Accept more test changes.
---
.../dataflow/local/DataFlowStep.expected | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/rust/ql/test/library-tests/dataflow/local/DataFlowStep.expected b/rust/ql/test/library-tests/dataflow/local/DataFlowStep.expected
index e403311345c..26ffdc13df6 100644
--- a/rust/ql/test/library-tests/dataflow/local/DataFlowStep.expected
+++ b/rust/ql/test/library-tests/dataflow/local/DataFlowStep.expected
@@ -1946,6 +1946,10 @@ models
| 1058 | Summary: lang:std; crate::thread::current::set_current; Argument[0]; ReturnValue.Field[crate::result::Result::Err(0)]; value |
| 1059 | Summary: lang:std; crate::thread::current::try_with_current; Argument[0].ReturnValue; ReturnValue; value |
| 1060 | Summary: lang:std; crate::thread::with_current_name; Argument[0].ReturnValue; ReturnValue; value |
+| 1061 | Summary: repo:https://github.com/fizyk20/generic-array.git:generic-array; ::from_mut_slice; Argument[0].Reference; ReturnValue.Reference; value |
+| 1062 | Summary: repo:https://github.com/fizyk20/generic-array.git:generic-array; ::from_slice; Argument[0].Reference; ReturnValue.Reference; value |
+| 1063 | Summary: repo:https://github.com/fizyk20/generic-array.git:generic-array; ::try_from_mut_slice; Argument[0].Reference; ReturnValue.Field[crate::result::Result::Ok(0)].Reference; value |
+| 1064 | Summary: repo:https://github.com/fizyk20/generic-array.git:generic-array; ::try_from_slice; Argument[0].Reference; ReturnValue.Field[crate::result::Result::Ok(0)].Reference; value |
storeStep
| file://:0:0:0:0 | [summary] to write: Argument[0].Field[crate::option::Option::Some(0)] in lang:core::_::::zip_with | Some | file://:0:0:0:0 | [post] [summary param] 0 in lang:core::_::::zip_with |
| file://:0:0:0:0 | [summary] to write: Argument[0].Parameter[0].Reference in lang:alloc::_::::retain | &ref | file://:0:0:0:0 | [summary] to write: Argument[0].Parameter[0] in lang:alloc::_::::retain |
@@ -2034,6 +2038,7 @@ storeStep
| file://:0:0:0:0 | [summary] to write: Argument[self].Reference.Reference in lang:std::_::<&[u8] as crate::io::Read>::read_to_end | &ref | file://:0:0:0:0 | [summary] to write: Argument[self].Reference in lang:std::_::<&[u8] as crate::io::Read>::read_to_end |
| file://:0:0:0:0 | [summary] to write: Argument[self].Reference.Reference in lang:std::_::<&[u8] as crate::io::Read>::read_to_string | &ref | file://:0:0:0:0 | [summary] to write: Argument[self].Reference in lang:std::_::<&[u8] as crate::io::Read>::read_to_string |
| file://:0:0:0:0 | [summary] to write: Argument[self].Reference.Reference in lang:std::_::<&[u8] as crate::io::copy::BufferedReaderSpec>::copy_to | &ref | file://:0:0:0:0 | [summary] to write: Argument[self].Reference in lang:std::_::<&[u8] as crate::io::copy::BufferedReaderSpec>::copy_to |
+| file://:0:0:0:0 | [summary] to write: ReturnValue.Element in lang:core::_::<_ as crate::convert::Into>::into | element | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:core::_::<_ as crate::convert::Into>::into |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Element in lang:core::_::::collect | element | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:core::_::::collect |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Element in lang:core::_::crate::cmp::minmax | element | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:core::_::crate::cmp::minmax |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Element in lang:core::_::crate::cmp::minmax_by | element | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:core::_::crate::cmp::minmax_by |
@@ -2071,12 +2076,20 @@ storeStep
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[0] in lang:core::_::::overflowing_div_euclid | tuple.0 | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:core::_::::overflowing_div_euclid |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[0] in lang:std::_::::into_parts | tuple.0 | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:std::_::::into_parts |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[0].Field[crate::option::Option::Some(0)] in lang:core::_::::unzip | Some | file://:0:0:0:0 | [summary] to write: ReturnValue.Field[0] in lang:core::_::::unzip |
+| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[0].Reference in lang:core::_::<[_]>::align_to | &ref | file://:0:0:0:0 | [summary] to write: ReturnValue.Field[0] in lang:core::_::<[_]>::align_to |
+| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[0].Reference.Element in lang:core::_::<[_]>::align_to | element | file://:0:0:0:0 | [summary] to write: ReturnValue.Field[0].Reference in lang:core::_::<[_]>::align_to |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[1] in lang:alloc::_::::find_lower_bound_edge | tuple.1 | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:alloc::_::::find_lower_bound_edge |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[1] in lang:alloc::_::::find_upper_bound_edge | tuple.1 | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:alloc::_::::find_upper_bound_edge |
+| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[1] in lang:core::_::<[_]>::align_to | tuple.1 | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:core::_::<[_]>::align_to |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[1] in lang:core::_::::unzip | tuple.1 | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:core::_::::unzip |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[1] in lang:core::_::crate::slice::sort::shared::find_existing_run | tuple.1 | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:core::_::crate::slice::sort::shared::find_existing_run |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[1] in lang:std::_::::into_parts | tuple.1 | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:std::_::::into_parts |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[1].Field[crate::option::Option::Some(0)] in lang:core::_::::unzip | Some | file://:0:0:0:0 | [summary] to write: ReturnValue.Field[1] in lang:core::_::::unzip |
+| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[1].Reference in lang:core::_::<[_]>::align_to | &ref | file://:0:0:0:0 | [summary] to write: ReturnValue.Field[1] in lang:core::_::<[_]>::align_to |
+| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[1].Reference.Element in lang:core::_::<[_]>::align_to | element | file://:0:0:0:0 | [summary] to write: ReturnValue.Field[1].Reference in lang:core::_::<[_]>::align_to |
+| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[2] in lang:core::_::<[_]>::align_to | tuple.2 | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:core::_::<[_]>::align_to |
+| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[2].Reference in lang:core::_::<[_]>::align_to | &ref | file://:0:0:0:0 | [summary] to write: ReturnValue.Field[2] in lang:core::_::<[_]>::align_to |
+| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[2].Reference.Element in lang:core::_::<[_]>::align_to | element | file://:0:0:0:0 | [summary] to write: ReturnValue.Field[2].Reference in lang:core::_::<[_]>::align_to |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::option::Option::Some(0)] in lang:core::_::::then | Some | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:core::_::::then |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::option::Option::Some(0)] in lang:core::_::::then_some | Some | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:core::_::::then_some |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::option::Option::Some(0)] in lang:core::_::::nth_back | Some | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:core::_::::nth_back |
@@ -2209,6 +2222,8 @@ storeStep
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::result::Result::Ok(0)] in lang:std::_::::wait_while | Ok | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:std::_::::wait_while |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::result::Result::Ok(0)] in lang:std::_::::try_with | Ok | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:std::_::::try_with |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::result::Result::Ok(0)] in lang:std::_::crate::sys::pal::unix::cvt | Ok | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:std::_::crate::sys::pal::unix::cvt |
+| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::result::Result::Ok(0)] in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::try_from_mut_slice | Ok | file://:0:0:0:0 | [summary] to write: ReturnValue in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::try_from_mut_slice |
+| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::result::Result::Ok(0)] in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::try_from_slice | Ok | file://:0:0:0:0 | [summary] to write: ReturnValue in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::try_from_slice |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::result::Result::Ok(0)] in repo:https://github.com/seanmonstar/reqwest:reqwest::_::::bytes | Ok | file://:0:0:0:0 | [summary] to write: ReturnValue in repo:https://github.com/seanmonstar/reqwest:reqwest::_::::bytes |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::result::Result::Ok(0)] in repo:https://github.com/seanmonstar/reqwest:reqwest::_::::text | Ok | file://:0:0:0:0 | [summary] to write: ReturnValue in repo:https://github.com/seanmonstar/reqwest:reqwest::_::::text |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::result::Result::Ok(0)] in repo:https://github.com/seanmonstar/reqwest:reqwest::_::::text_with_charset | Ok | file://:0:0:0:0 | [summary] to write: ReturnValue in repo:https://github.com/seanmonstar/reqwest:reqwest::_::::text_with_charset |
@@ -2225,6 +2240,8 @@ storeStep
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::result::Result::Ok(0)].Reference in lang:core::_::::try_insert | &ref | file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::result::Result::Ok(0)] in lang:core::_::::try_insert |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::result::Result::Ok(0)].Reference in lang:core::_::::as_mut | &ref | file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::result::Result::Ok(0)] in lang:core::_::::as_mut |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::result::Result::Ok(0)].Reference in lang:core::_::::as_ref | &ref | file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::result::Result::Ok(0)] in lang:core::_::::as_ref |
+| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::result::Result::Ok(0)].Reference in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::try_from_mut_slice | &ref | file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::result::Result::Ok(0)] in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::try_from_mut_slice |
+| file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::result::Result::Ok(0)].Reference in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::try_from_slice | &ref | file://:0:0:0:0 | [summary] to write: ReturnValue.Field[crate::result::Result::Ok(0)] in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::try_from_slice |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Reference in lang:alloc::_::::borrow | &ref | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:alloc::_::::borrow |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Reference in lang:alloc::_::::borrow | &ref | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:alloc::_::::borrow |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Reference in lang:alloc::_::::borrow_mut | &ref | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:alloc::_::::borrow_mut |
@@ -2304,6 +2321,8 @@ storeStep
| file://:0:0:0:0 | [summary] to write: ReturnValue.Reference in lang:std::_::::as_file_desc | &ref | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:std::_::::as_file_desc |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Reference in lang:std::_::<{486}::StaticStrPayload as crate::panic::PanicPayload>::get | &ref | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:std::_::<{486}::StaticStrPayload as crate::panic::PanicPayload>::get |
| file://:0:0:0:0 | [summary] to write: ReturnValue.Reference in lang:std::_::<{491}::RewrapBox as crate::panic::PanicPayload>::get | &ref | file://:0:0:0:0 | [summary] to write: ReturnValue in lang:std::_::<{491}::RewrapBox as crate::panic::PanicPayload>::get |
+| file://:0:0:0:0 | [summary] to write: ReturnValue.Reference in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::from_mut_slice | &ref | file://:0:0:0:0 | [summary] to write: ReturnValue in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::from_mut_slice |
+| file://:0:0:0:0 | [summary] to write: ReturnValue.Reference in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::from_slice | &ref | file://:0:0:0:0 | [summary] to write: ReturnValue in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::from_slice |
| main.rs:97:14:97:22 | source(...) | tuple.0 | main.rs:97:13:97:26 | TupleExpr |
| main.rs:97:25:97:25 | 2 | tuple.1 | main.rs:97:13:97:26 | TupleExpr |
| main.rs:103:14:103:14 | 2 | tuple.0 | main.rs:103:13:103:30 | TupleExpr |
@@ -2493,6 +2512,10 @@ readStep
| file://:0:0:0:0 | [summary param] 0 in lang:std::_::crate::sys_common::ignore_notfound | Err | file://:0:0:0:0 | [summary] read: Argument[0].Field[crate::result::Result::Err(0)] in lang:std::_::crate::sys_common::ignore_notfound |
| file://:0:0:0:0 | [summary param] 0 in lang:std::_::crate::thread::current::try_with_current | function return | file://:0:0:0:0 | [summary] read: Argument[0].ReturnValue in lang:std::_::crate::thread::current::try_with_current |
| file://:0:0:0:0 | [summary param] 0 in lang:std::_::crate::thread::with_current_name | function return | file://:0:0:0:0 | [summary] read: Argument[0].ReturnValue in lang:std::_::crate::thread::with_current_name |
+| file://:0:0:0:0 | [summary param] 0 in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::from_mut_slice | &ref | file://:0:0:0:0 | [summary] read: Argument[0].Reference in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::from_mut_slice |
+| file://:0:0:0:0 | [summary param] 0 in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::from_slice | &ref | file://:0:0:0:0 | [summary] read: Argument[0].Reference in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::from_slice |
+| file://:0:0:0:0 | [summary param] 0 in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::try_from_mut_slice | &ref | file://:0:0:0:0 | [summary] read: Argument[0].Reference in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::try_from_mut_slice |
+| file://:0:0:0:0 | [summary param] 0 in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::try_from_slice | &ref | file://:0:0:0:0 | [summary] read: Argument[0].Reference in repo:https://github.com/fizyk20/generic-array.git:generic-array::_::::try_from_slice |
| file://:0:0:0:0 | [summary param] 1 in lang:alloc::_::::fold | function return | file://:0:0:0:0 | [summary] read: Argument[1].ReturnValue in lang:alloc::_::::fold |
| file://:0:0:0:0 | [summary param] 1 in lang:alloc::_::crate::collections::btree::mem::replace | function return | file://:0:0:0:0 | [summary] read: Argument[1].ReturnValue in lang:alloc::_::crate::collections::btree::mem::replace |
| file://:0:0:0:0 | [summary param] 1 in lang:alloc::_::crate::collections::btree::mem::take_mut | function return | file://:0:0:0:0 | [summary] read: Argument[1].ReturnValue in lang:alloc::_::crate::collections::btree::mem::take_mut |
@@ -2629,6 +2652,9 @@ readStep
| file://:0:0:0:0 | [summary param] self in lang:core::_::<&mut _ as crate::borrow::BorrowMut>::borrow_mut | &ref | file://:0:0:0:0 | [summary] read: Argument[self].Reference in lang:core::_::<&mut _ as crate::borrow::BorrowMut>::borrow_mut |
| file://:0:0:0:0 | [summary param] self in lang:core::_::<&mut _ as crate::ops::deref::Deref>::deref | &ref | file://:0:0:0:0 | [summary] read: Argument[self].Reference in lang:core::_::<&mut _ as crate::ops::deref::Deref>::deref |
| file://:0:0:0:0 | [summary param] self in lang:core::_::<&mut _ as crate::ops::deref::DerefMut>::deref_mut | &ref | file://:0:0:0:0 | [summary] read: Argument[self].Reference in lang:core::_::<&mut _ as crate::ops::deref::DerefMut>::deref_mut |
+| file://:0:0:0:0 | [summary param] self in lang:core::_::<[_]>::align_to | element | file://:0:0:0:0 | [summary] read: Argument[self].Element in lang:core::_::<[_]>::align_to |
+| file://:0:0:0:0 | [summary param] self in lang:core::_::<_ as crate::convert::Into>::into | &ref | file://:0:0:0:0 | [summary] read: Argument[self].Reference in lang:core::_::<_ as crate::convert::Into>::into |
+| file://:0:0:0:0 | [summary param] self in lang:core::_::<_ as crate::convert::Into>::into | element | file://:0:0:0:0 | [summary] read: Argument[self].Element in lang:core::_::<_ as crate::convert::Into>::into |
| file://:0:0:0:0 | [summary param] self in lang:core::_::<_ as crate::str::pattern::MultiCharEq>::matches | &ref | file://:0:0:0:0 | [summary] read: Argument[self].Reference in lang:core::_::<_ as crate::str::pattern::MultiCharEq>::matches |
| file://:0:0:0:0 | [summary param] self in lang:core::_::::clone | &ref | file://:0:0:0:0 | [summary] read: Argument[self].Reference in lang:core::_::::clone |
| file://:0:0:0:0 | [summary param] self in lang:core::_::::clone | &ref | file://:0:0:0:0 | [summary] read: Argument[self].Reference in lang:core::_::::clone |
@@ -2923,6 +2949,7 @@ readStep
| file://:0:0:0:0 | [summary] read: Argument[self].Reference in lang:core::_::<&_ as crate::borrow::Borrow>::borrow | &ref | file://:0:0:0:0 | [summary] read: Argument[self].Reference.Reference in lang:core::_::<&_ as crate::borrow::Borrow>::borrow |
| file://:0:0:0:0 | [summary] read: Argument[self].Reference in lang:core::_::<&mut _ as crate::borrow::Borrow>::borrow | &ref | file://:0:0:0:0 | [summary] read: Argument[self].Reference.Reference in lang:core::_::<&mut _ as crate::borrow::Borrow>::borrow |
| file://:0:0:0:0 | [summary] read: Argument[self].Reference in lang:core::_::<&mut _ as crate::borrow::BorrowMut>::borrow_mut | &ref | file://:0:0:0:0 | [summary] read: Argument[self].Reference.Reference in lang:core::_::<&mut _ as crate::borrow::BorrowMut>::borrow_mut |
+| file://:0:0:0:0 | [summary] read: Argument[self].Reference in lang:core::_::<_ as crate::convert::Into>::into | element | file://:0:0:0:0 | [summary] read: Argument[self].Reference.Element in lang:core::_::<_ as crate::convert::Into>::into |
| file://:0:0:0:0 | [summary] read: Argument[self].Reference in lang:core::_::<_ as crate::str::pattern::MultiCharEq>::matches | function return | file://:0:0:0:0 | [summary] read: Argument[self].Reference.ReturnValue in lang:core::_::<_ as crate::str::pattern::MultiCharEq>::matches |
| file://:0:0:0:0 | [summary] read: Argument[self].Reference in lang:core::_::::as_mut | Some | file://:0:0:0:0 | [summary] read: Argument[self].Reference.Field[crate::option::Option::Some(0)] in lang:core::_::::as_mut |
| file://:0:0:0:0 | [summary] read: Argument[self].Reference in lang:core::_::::as_ref | Some | file://:0:0:0:0 | [summary] read: Argument[self].Reference.Field[crate::option::Option::Some(0)] in lang:core::_::::as_ref |
From b4e710f459636b286cc344f9e0b31c9040ab5481 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Fri, 7 Mar 2025 21:25:15 +0000
Subject: [PATCH 017/534] Rust: Add missing models (for some platforms???).
---
.../rustcrypto/rustcrypto.model.yml | 3 ++
.../HardcodedCryptographicValue.expected | 54 +++++++++----------
2 files changed, 30 insertions(+), 27 deletions(-)
diff --git a/rust/ql/lib/codeql/rust/frameworks/rustcrypto/rustcrypto.model.yml b/rust/ql/lib/codeql/rust/frameworks/rustcrypto/rustcrypto.model.yml
index 2047cfa9ebc..3c588473514 100644
--- a/rust/ql/lib/codeql/rust/frameworks/rustcrypto/rustcrypto.model.yml
+++ b/rust/ql/lib/codeql/rust/frameworks/rustcrypto/rustcrypto.model.yml
@@ -9,6 +9,7 @@ extensions:
- ["repo:https://github.com/RustCrypto/traits:digest", "<_ as crate::digest::Digest>::digest", "Argument[0]", "hasher-input", "manual"]
- ["repo:https://github.com/stainless-steel/md5:md5", "crate::compute", "Argument[0]", "hasher-input", "manual"]
- ["repo:https://github.com/RustCrypto/traits:cipher", "::new", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/traits:cipher", "::new", "Argument[1]", "credentials-iv", "manual"]
- ["repo:https://github.com/RustCrypto/traits:cipher", "::new_from_slice", "Argument[0]", "credentials-key", "manual"]
- ["repo:https://github.com/RustCrypto/traits:cipher", "::new", "Argument[0]", "credentials-key", "manual"]
- ["repo:https://github.com/RustCrypto/traits:cipher", "::new", "Argument[1]", "credentials-iv", "manual"]
@@ -28,6 +29,8 @@ extensions:
- ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new_from_slice", "Argument[0]", "credentials-key", "manual"]
- ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new", "Argument[0]", "credentials-key", "manual"]
- ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new_from_slice", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new", "Argument[0]", "credentials-key", "manual"]
+ - ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new_from_slice", "Argument[0]", "credentials-key", "manual"]
- ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new", "Argument[0]", "credentials-key", "manual"]
- ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new_from_slice", "Argument[0]", "credentials-key", "manual"]
- ["repo:https://github.com/RustCrypto/block-ciphers:aes", "::new", "Argument[0]", "credentials-key", "manual"]
diff --git a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
index a8ce502c403..726934d5d98 100644
--- a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
+++ b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
@@ -19,78 +19,78 @@ edges
| test_cipher.rs:18:28:18:36 | &... [&ref, element] | test_cipher.rs:18:9:18:14 | const1 [&ref, element] | provenance | |
| test_cipher.rs:18:29:18:36 | [0u8; 16] [element] | test_cipher.rs:18:28:18:36 | &... [&ref, element] | provenance | |
| test_cipher.rs:18:30:18:32 | 0u8 | test_cipher.rs:18:29:18:36 | [0u8; 16] [element] | provenance | |
-| test_cipher.rs:19:49:19:79 | ...::from_slice(...) [&ref, element] | test_cipher.rs:19:30:19:47 | ...::new | provenance | MaD:60 Sink:MaD:60 Sink:MaD:60 |
+| test_cipher.rs:19:49:19:79 | ...::from_slice(...) [&ref, element] | test_cipher.rs:19:30:19:47 | ...::new | provenance | MaD:61 Sink:MaD:61 Sink:MaD:61 |
| test_cipher.rs:19:73:19:78 | const1 [&ref, element] | test_cipher.rs:19:49:19:79 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
| test_cipher.rs:25:9:25:14 | const4 [&ref, element] | test_cipher.rs:26:66:26:71 | const4 [&ref, element] | provenance | |
| test_cipher.rs:25:28:25:36 | &... [&ref, element] | test_cipher.rs:25:9:25:14 | const4 [&ref, element] | provenance | |
| test_cipher.rs:25:29:25:36 | [0u8; 16] [element] | test_cipher.rs:25:28:25:36 | &... [&ref, element] | provenance | |
| test_cipher.rs:25:30:25:32 | 0u8 | test_cipher.rs:25:29:25:36 | [0u8; 16] [element] | provenance | |
-| test_cipher.rs:26:42:26:72 | ...::from_slice(...) [&ref, element] | test_cipher.rs:26:30:26:40 | ...::new | provenance | MaD:60 Sink:MaD:60 Sink:MaD:60 |
+| test_cipher.rs:26:42:26:72 | ...::from_slice(...) [&ref, element] | test_cipher.rs:26:30:26:40 | ...::new | provenance | MaD:61 Sink:MaD:61 Sink:MaD:61 |
| test_cipher.rs:26:66:26:71 | const4 [&ref, element] | test_cipher.rs:26:42:26:72 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
| test_cipher.rs:29:9:29:14 | const5 [&ref, element] | test_cipher.rs:30:95:30:100 | const5 [&ref, element] | provenance | |
| test_cipher.rs:29:28:29:36 | &... [&ref, element] | test_cipher.rs:29:9:29:14 | const5 [&ref, element] | provenance | |
| test_cipher.rs:29:29:29:36 | [0u8; 16] [element] | test_cipher.rs:29:28:29:36 | &... [&ref, element] | provenance | |
| test_cipher.rs:29:30:29:32 | 0u8 | test_cipher.rs:29:29:29:36 | [0u8; 16] [element] | provenance | |
-| test_cipher.rs:30:72:30:101 | ...::from_slice(...) [&ref, element] | test_cipher.rs:30:30:30:40 | ...::new | provenance | MaD:61 Sink:MaD:61 Sink:MaD:61 |
+| test_cipher.rs:30:72:30:101 | ...::from_slice(...) [&ref, element] | test_cipher.rs:30:30:30:40 | ...::new | provenance | MaD:62 Sink:MaD:62 Sink:MaD:62 |
| test_cipher.rs:30:95:30:100 | const5 [&ref, element] | test_cipher.rs:30:72:30:101 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
| test_cipher.rs:37:9:37:14 | const7 | test_cipher.rs:38:74:38:79 | const7 | provenance | |
| test_cipher.rs:37:27:37:74 | [...] | test_cipher.rs:37:9:37:14 | const7 | provenance | |
-| test_cipher.rs:38:49:38:80 | ...::from_slice(...) [&ref] | test_cipher.rs:38:30:38:47 | ...::new | provenance | MaD:60 Sink:MaD:60 |
+| test_cipher.rs:38:49:38:80 | ...::from_slice(...) [&ref] | test_cipher.rs:38:30:38:47 | ...::new | provenance | MaD:61 Sink:MaD:61 |
| test_cipher.rs:38:73:38:79 | &const7 [&ref] | test_cipher.rs:38:49:38:80 | ...::from_slice(...) [&ref] | provenance | MaD:0 |
| test_cipher.rs:38:74:38:79 | const7 | test_cipher.rs:38:73:38:79 | &const7 [&ref] | provenance | |
| test_cipher.rs:41:9:41:14 | const8 [&ref] | test_cipher.rs:42:73:42:78 | const8 [&ref] | provenance | |
| test_cipher.rs:41:28:41:76 | &... [&ref] | test_cipher.rs:41:9:41:14 | const8 [&ref] | provenance | |
| test_cipher.rs:41:29:41:76 | [...] | test_cipher.rs:41:28:41:76 | &... [&ref] | provenance | |
-| test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref] | test_cipher.rs:42:30:42:47 | ...::new | provenance | MaD:60 Sink:MaD:60 |
+| test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref] | test_cipher.rs:42:30:42:47 | ...::new | provenance | MaD:61 Sink:MaD:61 |
| test_cipher.rs:42:73:42:78 | const8 [&ref] | test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref] | provenance | MaD:0 |
-| test_cipher.rs:45:9:45:14 | const9 | test_cipher.rs:46:32:46:54 | const9.align_to(...) [tuple.1, &ref, element] | provenance | MaD:104 |
+| test_cipher.rs:45:9:45:14 | const9 | test_cipher.rs:46:32:46:54 | const9.align_to(...) [tuple.1, &ref, element] | provenance | MaD:107 |
| test_cipher.rs:45:27:45:50 | [...] | test_cipher.rs:45:9:45:14 | const9 | provenance | |
| test_cipher.rs:46:9:46:19 | const9_conv [&ref, element] | test_cipher.rs:47:73:47:83 | const9_conv [&ref, element] | provenance | |
| test_cipher.rs:46:32:46:54 | const9.align_to(...) [tuple.1, &ref, element] | test_cipher.rs:46:32:46:56 | ... .1 [&ref, element] | provenance | |
| test_cipher.rs:46:32:46:56 | ... .1 [&ref, element] | test_cipher.rs:46:9:46:19 | const9_conv [&ref, element] | provenance | |
-| test_cipher.rs:47:49:47:84 | ...::from_slice(...) [&ref, element] | test_cipher.rs:47:30:47:47 | ...::new | provenance | MaD:60 Sink:MaD:60 Sink:MaD:60 |
+| test_cipher.rs:47:49:47:84 | ...::from_slice(...) [&ref, element] | test_cipher.rs:47:30:47:47 | ...::new | provenance | MaD:61 Sink:MaD:61 Sink:MaD:61 |
| test_cipher.rs:47:73:47:83 | const9_conv [&ref, element] | test_cipher.rs:47:49:47:84 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
| test_cipher.rs:50:9:50:15 | const10 [element] | test_cipher.rs:51:75:51:81 | const10 [element] | provenance | |
-| test_cipher.rs:50:37:50:52 | ...::zeroed | test_cipher.rs:50:37:50:54 | ...::zeroed(...) [element] | provenance | Src:MaD:101 |
+| test_cipher.rs:50:37:50:52 | ...::zeroed | test_cipher.rs:50:37:50:54 | ...::zeroed(...) [element] | provenance | Src:MaD:104 |
| test_cipher.rs:50:37:50:54 | ...::zeroed(...) [element] | test_cipher.rs:50:9:50:15 | const10 [element] | provenance | |
-| test_cipher.rs:51:50:51:82 | ...::from_slice(...) [&ref, element] | test_cipher.rs:51:31:51:48 | ...::new | provenance | MaD:60 Sink:MaD:60 Sink:MaD:60 |
+| test_cipher.rs:51:50:51:82 | ...::from_slice(...) [&ref, element] | test_cipher.rs:51:31:51:48 | ...::new | provenance | MaD:61 Sink:MaD:61 Sink:MaD:61 |
| test_cipher.rs:51:74:51:81 | &const10 [&ref, element] | test_cipher.rs:51:50:51:82 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
| test_cipher.rs:51:75:51:81 | const10 [element] | test_cipher.rs:51:74:51:81 | &const10 [&ref, element] | provenance | |
| test_cipher.rs:66:9:66:14 | const2 [&ref, element] | test_cipher.rs:67:35:67:40 | const2 [&ref, element] | provenance | |
-| test_cipher.rs:66:9:66:14 | const2 [&ref, element] | test_cipher.rs:67:35:67:47 | const2.into(...) [element] | provenance | MaD:103 |
+| test_cipher.rs:66:9:66:14 | const2 [&ref, element] | test_cipher.rs:67:35:67:47 | const2.into(...) [element] | provenance | MaD:106 |
| test_cipher.rs:66:18:66:26 | &... [&ref, element] | test_cipher.rs:66:9:66:14 | const2 [&ref, element] | provenance | |
| test_cipher.rs:66:19:66:26 | [0u8; 32] [element] | test_cipher.rs:66:18:66:26 | &... [&ref, element] | provenance | |
| test_cipher.rs:66:20:66:22 | 0u8 | test_cipher.rs:66:19:66:26 | [0u8; 32] [element] | provenance | |
-| test_cipher.rs:67:35:67:40 | const2 [&ref, element] | test_cipher.rs:67:35:67:47 | const2.into(...) [element] | provenance | MaD:102 |
-| test_cipher.rs:67:35:67:47 | const2.into(...) [element] | test_cipher.rs:67:23:67:33 | ...::new | provenance | MaD:76 Sink:MaD:76 |
+| test_cipher.rs:67:35:67:40 | const2 [&ref, element] | test_cipher.rs:67:35:67:47 | const2.into(...) [element] | provenance | MaD:105 |
+| test_cipher.rs:67:35:67:47 | const2.into(...) [element] | test_cipher.rs:67:23:67:33 | ...::new | provenance | MaD:77 Sink:MaD:77 |
| test_cipher.rs:73:9:73:14 | const2 [&ref, element] | test_cipher.rs:74:46:74:51 | const2 [&ref, element] | provenance | |
| test_cipher.rs:73:18:73:26 | &... [&ref, element] | test_cipher.rs:73:9:73:14 | const2 [&ref, element] | provenance | |
| test_cipher.rs:73:19:73:26 | [0u8; 32] [element] | test_cipher.rs:73:18:73:26 | &... [&ref, element] | provenance | |
| test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:73:19:73:26 | [0u8; 32] [element] | provenance | |
-| test_cipher.rs:74:46:74:51 | const2 [&ref, element] | test_cipher.rs:74:23:74:44 | ...::new_from_slice | provenance | MaD:84 Sink:MaD:84 Sink:MaD:84 |
+| test_cipher.rs:74:46:74:51 | const2 [&ref, element] | test_cipher.rs:74:23:74:44 | ...::new_from_slice | provenance | MaD:87 Sink:MaD:87 Sink:MaD:87 |
| test_cipher.rs:80:9:80:14 | const6 [&ref, element] | test_cipher.rs:81:63:81:68 | const6 [&ref, element] | provenance | |
-| test_cipher.rs:80:9:80:14 | const6 [&ref, element] | test_cipher.rs:81:63:81:75 | const6.into(...) [element] | provenance | MaD:103 |
+| test_cipher.rs:80:9:80:14 | const6 [&ref, element] | test_cipher.rs:81:63:81:75 | const6.into(...) [element] | provenance | MaD:106 |
| test_cipher.rs:80:18:80:26 | &... [&ref, element] | test_cipher.rs:80:9:80:14 | const6 [&ref, element] | provenance | |
| test_cipher.rs:80:19:80:26 | [0u8; 32] [element] | test_cipher.rs:80:18:80:26 | &... [&ref, element] | provenance | |
| test_cipher.rs:80:20:80:22 | 0u8 | test_cipher.rs:80:19:80:26 | [0u8; 32] [element] | provenance | |
-| test_cipher.rs:81:63:81:68 | const6 [&ref, element] | test_cipher.rs:81:63:81:75 | const6.into(...) [element] | provenance | MaD:102 |
-| test_cipher.rs:81:63:81:75 | const6.into(...) [element] | test_cipher.rs:81:23:81:61 | ...::new | provenance | MaD:86 Sink:MaD:86 |
+| test_cipher.rs:81:63:81:68 | const6 [&ref, element] | test_cipher.rs:81:63:81:75 | const6.into(...) [element] | provenance | MaD:105 |
+| test_cipher.rs:81:63:81:75 | const6.into(...) [element] | test_cipher.rs:81:23:81:61 | ...::new | provenance | MaD:89 Sink:MaD:89 |
| test_cipher.rs:84:9:84:14 | const7 [&ref, element] | test_cipher.rs:85:75:85:80 | const7 [&ref, element] | provenance | |
-| test_cipher.rs:84:9:84:14 | const7 [&ref, element] | test_cipher.rs:85:75:85:87 | const7.into(...) [element] | provenance | MaD:103 |
+| test_cipher.rs:84:9:84:14 | const7 [&ref, element] | test_cipher.rs:85:75:85:87 | const7.into(...) [element] | provenance | MaD:106 |
| test_cipher.rs:84:18:84:27 | &... [&ref, element] | test_cipher.rs:84:9:84:14 | const7 [&ref, element] | provenance | |
| test_cipher.rs:84:19:84:27 | [0u8; 16] [element] | test_cipher.rs:84:18:84:27 | &... [&ref, element] | provenance | |
| test_cipher.rs:84:20:84:22 | 0u8 | test_cipher.rs:84:19:84:27 | [0u8; 16] [element] | provenance | |
-| test_cipher.rs:85:75:85:80 | const7 [&ref, element] | test_cipher.rs:85:75:85:87 | const7.into(...) [element] | provenance | MaD:102 |
-| test_cipher.rs:85:75:85:87 | const7.into(...) [element] | test_cipher.rs:85:23:85:61 | ...::new | provenance | MaD:87 Sink:MaD:87 |
-| test_cipher.rs:124:9:124:12 | key2 [element] | test_cipher.rs:126:35:126:45 | key2.into(...) [element] | provenance | MaD:102 |
+| test_cipher.rs:85:75:85:80 | const7 [&ref, element] | test_cipher.rs:85:75:85:87 | const7.into(...) [element] | provenance | MaD:105 |
+| test_cipher.rs:85:75:85:87 | const7.into(...) [element] | test_cipher.rs:85:23:85:61 | ...::new | provenance | MaD:90 Sink:MaD:90 |
+| test_cipher.rs:124:9:124:12 | key2 [element] | test_cipher.rs:126:35:126:45 | key2.into(...) [element] | provenance | MaD:105 |
| test_cipher.rs:124:25:124:30 | [0; 32] [element] | test_cipher.rs:124:9:124:12 | key2 [element] | provenance | |
| test_cipher.rs:124:26:124:26 | 0 | test_cipher.rs:124:25:124:30 | [0; 32] [element] | provenance | |
-| test_cipher.rs:125:9:125:14 | nonce2 [element] | test_cipher.rs:127:30:127:42 | nonce2.into(...) [element] | provenance | MaD:102 |
+| test_cipher.rs:125:9:125:14 | nonce2 [element] | test_cipher.rs:127:30:127:42 | nonce2.into(...) [element] | provenance | MaD:105 |
| test_cipher.rs:125:18:125:23 | [0; 12] [element] | test_cipher.rs:125:9:125:14 | nonce2 [element] | provenance | |
| test_cipher.rs:125:19:125:19 | 0 | test_cipher.rs:125:18:125:23 | [0; 12] [element] | provenance | |
-| test_cipher.rs:126:34:126:45 | &... [&ref, element] | test_cipher.rs:126:19:126:32 | ...::new | provenance | MaD:90 Sink:MaD:90 Sink:MaD:90 |
+| test_cipher.rs:126:34:126:45 | &... [&ref, element] | test_cipher.rs:126:19:126:32 | ...::new | provenance | MaD:93 Sink:MaD:93 Sink:MaD:93 |
| test_cipher.rs:126:35:126:45 | key2.into(...) [element] | test_cipher.rs:126:34:126:45 | &... [&ref, element] | provenance | |
-| test_cipher.rs:127:29:127:42 | &... [&ref, element] | test_cipher.rs:127:21:127:27 | encrypt | provenance | MaD:91 Sink:MaD:91 Sink:MaD:91 |
+| test_cipher.rs:127:29:127:42 | &... [&ref, element] | test_cipher.rs:127:21:127:27 | encrypt | provenance | MaD:94 Sink:MaD:94 Sink:MaD:94 |
| test_cipher.rs:127:30:127:42 | nonce2.into(...) [element] | test_cipher.rs:127:29:127:42 | &... [&ref, element] | provenance | |
| test_cipher.rs:129:9:129:18 | key3_array [&ref, element] | test_cipher.rs:130:45:130:54 | key3_array [&ref, element] | provenance | |
| test_cipher.rs:129:32:129:41 | &... [&ref, element] | test_cipher.rs:129:9:129:18 | key3_array [&ref, element] | provenance | |
@@ -99,13 +99,13 @@ edges
| test_cipher.rs:130:9:130:12 | key3 [&ref, element] | test_cipher.rs:132:35:132:38 | key3 [&ref, element] | provenance | |
| test_cipher.rs:130:16:130:55 | ...::from_slice(...) [&ref, element] | test_cipher.rs:130:9:130:12 | key3 [&ref, element] | provenance | |
| test_cipher.rs:130:45:130:54 | key3_array [&ref, element] | test_cipher.rs:130:16:130:55 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
-| test_cipher.rs:131:9:131:14 | nonce3 [element] | test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | provenance | MaD:102 |
+| test_cipher.rs:131:9:131:14 | nonce3 [element] | test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | provenance | MaD:105 |
| test_cipher.rs:131:27:131:35 | [0xff; 12] [element] | test_cipher.rs:131:9:131:14 | nonce3 [element] | provenance | |
| test_cipher.rs:131:28:131:31 | 0xff | test_cipher.rs:131:27:131:35 | [0xff; 12] [element] | provenance | |
-| test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | test_cipher.rs:132:19:132:32 | ...::new | provenance | MaD:90 Sink:MaD:90 Sink:MaD:90 |
-| test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | test_cipher.rs:132:19:132:32 | ...::new | provenance | MaD:90 Sink:MaD:90 Sink:MaD:90 Sink:MaD:90 |
+| test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | test_cipher.rs:132:19:132:32 | ...::new | provenance | MaD:93 Sink:MaD:93 Sink:MaD:93 |
+| test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | test_cipher.rs:132:19:132:32 | ...::new | provenance | MaD:93 Sink:MaD:93 Sink:MaD:93 Sink:MaD:93 |
| test_cipher.rs:132:35:132:38 | key3 [&ref, element] | test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | provenance | |
-| test_cipher.rs:133:29:133:42 | &... [&ref, element] | test_cipher.rs:133:21:133:27 | encrypt | provenance | MaD:91 Sink:MaD:91 Sink:MaD:91 |
+| test_cipher.rs:133:29:133:42 | &... [&ref, element] | test_cipher.rs:133:21:133:27 | encrypt | provenance | MaD:94 Sink:MaD:94 Sink:MaD:94 |
| test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | test_cipher.rs:133:29:133:42 | &... [&ref, element] | provenance | |
nodes
| test_cipher.rs:18:9:18:14 | const1 [&ref, element] | semmle.label | const1 [&ref, element] |
From e84a98bd975a4bd23ccaa6e375b205cac0d076c5 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Mon, 10 Mar 2025 11:15:23 +0000
Subject: [PATCH 018/534] Apply suggestions from code review
Co-authored-by: mc <42146119+mchammer01@users.noreply.github.com>
---
.../security/CWE-798/HardcodedCryptographicValue.qhelp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.qhelp b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.qhelp
index b44a98013c8..f3b2d831944 100644
--- a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.qhelp
+++ b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.qhelp
@@ -5,7 +5,7 @@
-Hardcoded passwords, keys, initialization vectors and salts should not be used for cryptographic operations.
+Hardcoded passwords, keys, initialization vectors, and salts should not be used for cryptographic operations.
-
@@ -23,7 +23,7 @@ Hardcoded passwords, keys, initialization vectors and salts should not be used f
-Use randomly generated key material, initialization vectors and salts. Use strong passwords that are not hardcoded.
+Use randomly generated key material, initialization vectors, and salts. Use strong passwords that are not hardcoded.
From a34f9bef2b271019505276215e7c2d1b29e38c3a Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Mon, 10 Mar 2025 11:33:29 +0000
Subject: [PATCH 019/534] Rust: Add a test case for getrandom.
---
.../HardcodedCryptographicValue.expected | 24 +++++++++++++++++++
.../query-tests/security/CWE-798/options.yml | 2 ++
.../security/CWE-798/test_cipher.rs | 9 +++++++
3 files changed, 35 insertions(+)
diff --git a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
index 726934d5d98..17ac5044b05 100644
--- a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
+++ b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
@@ -14,6 +14,8 @@
| test_cipher.rs:125:19:125:19 | 0 | test_cipher.rs:125:19:125:19 | 0 | test_cipher.rs:127:21:127:27 | encrypt | This hard-coded value is used as $@. | test_cipher.rs:127:21:127:27 | encrypt | a nonce |
| test_cipher.rs:129:34:129:37 | 0xff | test_cipher.rs:129:34:129:37 | 0xff | test_cipher.rs:132:19:132:32 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:132:19:132:32 | ...::new | a key |
| test_cipher.rs:131:28:131:31 | 0xff | test_cipher.rs:131:28:131:31 | 0xff | test_cipher.rs:133:21:133:27 | encrypt | This hard-coded value is used as $@. | test_cipher.rs:133:21:133:27 | encrypt | a nonce |
+| test_cipher.rs:137:21:137:23 | 0u8 | test_cipher.rs:137:21:137:23 | 0u8 | test_cipher.rs:141:19:141:32 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:141:19:141:32 | ...::new | a key |
+| test_cipher.rs:138:23:138:25 | 0u8 | test_cipher.rs:138:23:138:25 | 0u8 | test_cipher.rs:142:21:142:27 | encrypt | This hard-coded value is used as $@. | test_cipher.rs:142:21:142:27 | encrypt | a nonce |
edges
| test_cipher.rs:18:9:18:14 | const1 [&ref, element] | test_cipher.rs:19:73:19:78 | const1 [&ref, element] | provenance | |
| test_cipher.rs:18:28:18:36 | &... [&ref, element] | test_cipher.rs:18:9:18:14 | const1 [&ref, element] | provenance | |
@@ -107,6 +109,16 @@ edges
| test_cipher.rs:132:35:132:38 | key3 [&ref, element] | test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | provenance | |
| test_cipher.rs:133:29:133:42 | &... [&ref, element] | test_cipher.rs:133:21:133:27 | encrypt | provenance | MaD:94 Sink:MaD:94 Sink:MaD:94 |
| test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | test_cipher.rs:133:29:133:42 | &... [&ref, element] | provenance | |
+| test_cipher.rs:137:9:137:16 | mut key4 [element] | test_cipher.rs:141:35:141:45 | key4.into(...) [element] | provenance | MaD:105 |
+| test_cipher.rs:137:20:137:27 | [0u8; 32] [element] | test_cipher.rs:137:9:137:16 | mut key4 [element] | provenance | |
+| test_cipher.rs:137:21:137:23 | 0u8 | test_cipher.rs:137:20:137:27 | [0u8; 32] [element] | provenance | |
+| test_cipher.rs:138:9:138:18 | mut nonce4 [element] | test_cipher.rs:142:30:142:42 | nonce4.into(...) [element] | provenance | MaD:105 |
+| test_cipher.rs:138:22:138:29 | [0u8; 12] [element] | test_cipher.rs:138:9:138:18 | mut nonce4 [element] | provenance | |
+| test_cipher.rs:138:23:138:25 | 0u8 | test_cipher.rs:138:22:138:29 | [0u8; 12] [element] | provenance | |
+| test_cipher.rs:141:34:141:45 | &... [&ref, element] | test_cipher.rs:141:19:141:32 | ...::new | provenance | MaD:93 Sink:MaD:93 Sink:MaD:93 |
+| test_cipher.rs:141:35:141:45 | key4.into(...) [element] | test_cipher.rs:141:34:141:45 | &... [&ref, element] | provenance | |
+| test_cipher.rs:142:29:142:42 | &... [&ref, element] | test_cipher.rs:142:21:142:27 | encrypt | provenance | MaD:94 Sink:MaD:94 Sink:MaD:94 |
+| test_cipher.rs:142:30:142:42 | nonce4.into(...) [element] | test_cipher.rs:142:29:142:42 | &... [&ref, element] | provenance | |
nodes
| test_cipher.rs:18:9:18:14 | const1 [&ref, element] | semmle.label | const1 [&ref, element] |
| test_cipher.rs:18:28:18:36 | &... [&ref, element] | semmle.label | &... [&ref, element] |
@@ -211,4 +223,16 @@ nodes
| test_cipher.rs:133:21:133:27 | encrypt | semmle.label | encrypt |
| test_cipher.rs:133:29:133:42 | &... [&ref, element] | semmle.label | &... [&ref, element] |
| test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | semmle.label | nonce3.into(...) [element] |
+| test_cipher.rs:137:9:137:16 | mut key4 [element] | semmle.label | mut key4 [element] |
+| test_cipher.rs:137:20:137:27 | [0u8; 32] [element] | semmle.label | [0u8; 32] [element] |
+| test_cipher.rs:137:21:137:23 | 0u8 | semmle.label | 0u8 |
+| test_cipher.rs:138:9:138:18 | mut nonce4 [element] | semmle.label | mut nonce4 [element] |
+| test_cipher.rs:138:22:138:29 | [0u8; 12] [element] | semmle.label | [0u8; 12] [element] |
+| test_cipher.rs:138:23:138:25 | 0u8 | semmle.label | 0u8 |
+| test_cipher.rs:141:19:141:32 | ...::new | semmle.label | ...::new |
+| test_cipher.rs:141:34:141:45 | &... [&ref, element] | semmle.label | &... [&ref, element] |
+| test_cipher.rs:141:35:141:45 | key4.into(...) [element] | semmle.label | key4.into(...) [element] |
+| test_cipher.rs:142:21:142:27 | encrypt | semmle.label | encrypt |
+| test_cipher.rs:142:29:142:42 | &... [&ref, element] | semmle.label | &... [&ref, element] |
+| test_cipher.rs:142:30:142:42 | nonce4.into(...) [element] | semmle.label | nonce4.into(...) [element] |
subpaths
diff --git a/rust/ql/test/query-tests/security/CWE-798/options.yml b/rust/ql/test/query-tests/security/CWE-798/options.yml
index aff715ea271..6713251d3eb 100644
--- a/rust/ql/test/query-tests/security/CWE-798/options.yml
+++ b/rust/ql/test/query-tests/security/CWE-798/options.yml
@@ -6,3 +6,5 @@ qltest_dependencies:
- aes-gcm = { version = "0.10.3" }
- cfb-mode = { version = "0.8.2" }
- base64 = { version = "0.22.1" }
+ - getrandom = { version = "0.3.1" }
+ - getrandom2 = { package = "getrandom", version = "0.2.15" }
diff --git a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
index 7a5ef0572fd..a72eaebb303 100644
--- a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
+++ b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
@@ -131,4 +131,13 @@ fn test_aes_gcm(
let nonce3: [u8;12] = [0xff;12]; // $ Alert[rust/hardcoded-cryptographic-value]
let cipher3 = Aes256Gcm::new(&key3); // $ Sink
let _ = cipher3.encrypt(&nonce3.into(), b"plaintext".as_ref()).unwrap(); // $ Sink
+
+ // with barrier
+
+ let mut key4 = [0u8;32]; // $ SPURIOUS: Alert[rust/hardcoded-cryptographic-value]
+ let mut nonce4 = [0u8;12]; // $ SPURIOUS: Alert[rust/hardcoded-cryptographic-value]
+ _ = getrandom::fill(&mut key4).unwrap();
+ _ = getrandom2::getrandom(&mut nonce4).unwrap();
+ let cipher4 = Aes256Gcm::new(&key4.into()); // $ Sink
+ let _ = cipher2.encrypt(&nonce4.into(), b"plaintext".as_ref()).unwrap(); // $ Sink
}
From 9e54d5353743bdff81581b465c1914e3899cbee2 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Mon, 10 Mar 2025 11:40:29 +0000
Subject: [PATCH 020/534] Rust: Add barrier.
---
.../HardcodedCryptographicValueExtensions.qll | 14 +++++++++++
.../HardcodedCryptographicValue.expected | 24 -------------------
.../security/CWE-798/test_cipher.rs | 8 +++----
3 files changed, 18 insertions(+), 28 deletions(-)
diff --git a/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll b/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
index 32f64051fcb..b6ed9d6091e 100644
--- a/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
+++ b/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
@@ -89,4 +89,18 @@ module HardcodedCryptographicValue {
override CryptographicValueKind getKind() { result = kind }
}
+
+ /**
+ * A call to `getrandom` that is a barrier.
+ */
+ private class GetRandomBarrier extends Barrier {
+ GetRandomBarrier() {
+ exists(CallExpr ce |
+ ce.getFunction().(PathExpr).getResolvedCrateOrigin() =
+ "repo:https://github.com/rust-random/getrandom:getrandom" and
+ ce.getFunction().(PathExpr).getResolvedPath() = ["crate::fill", "crate::getrandom"] and
+ this.asExpr().getExpr().getParentNode*() = ce.getArgList().getArg(0)
+ )
+ }
+ }
}
diff --git a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
index 17ac5044b05..726934d5d98 100644
--- a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
+++ b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
@@ -14,8 +14,6 @@
| test_cipher.rs:125:19:125:19 | 0 | test_cipher.rs:125:19:125:19 | 0 | test_cipher.rs:127:21:127:27 | encrypt | This hard-coded value is used as $@. | test_cipher.rs:127:21:127:27 | encrypt | a nonce |
| test_cipher.rs:129:34:129:37 | 0xff | test_cipher.rs:129:34:129:37 | 0xff | test_cipher.rs:132:19:132:32 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:132:19:132:32 | ...::new | a key |
| test_cipher.rs:131:28:131:31 | 0xff | test_cipher.rs:131:28:131:31 | 0xff | test_cipher.rs:133:21:133:27 | encrypt | This hard-coded value is used as $@. | test_cipher.rs:133:21:133:27 | encrypt | a nonce |
-| test_cipher.rs:137:21:137:23 | 0u8 | test_cipher.rs:137:21:137:23 | 0u8 | test_cipher.rs:141:19:141:32 | ...::new | This hard-coded value is used as $@. | test_cipher.rs:141:19:141:32 | ...::new | a key |
-| test_cipher.rs:138:23:138:25 | 0u8 | test_cipher.rs:138:23:138:25 | 0u8 | test_cipher.rs:142:21:142:27 | encrypt | This hard-coded value is used as $@. | test_cipher.rs:142:21:142:27 | encrypt | a nonce |
edges
| test_cipher.rs:18:9:18:14 | const1 [&ref, element] | test_cipher.rs:19:73:19:78 | const1 [&ref, element] | provenance | |
| test_cipher.rs:18:28:18:36 | &... [&ref, element] | test_cipher.rs:18:9:18:14 | const1 [&ref, element] | provenance | |
@@ -109,16 +107,6 @@ edges
| test_cipher.rs:132:35:132:38 | key3 [&ref, element] | test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | provenance | |
| test_cipher.rs:133:29:133:42 | &... [&ref, element] | test_cipher.rs:133:21:133:27 | encrypt | provenance | MaD:94 Sink:MaD:94 Sink:MaD:94 |
| test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | test_cipher.rs:133:29:133:42 | &... [&ref, element] | provenance | |
-| test_cipher.rs:137:9:137:16 | mut key4 [element] | test_cipher.rs:141:35:141:45 | key4.into(...) [element] | provenance | MaD:105 |
-| test_cipher.rs:137:20:137:27 | [0u8; 32] [element] | test_cipher.rs:137:9:137:16 | mut key4 [element] | provenance | |
-| test_cipher.rs:137:21:137:23 | 0u8 | test_cipher.rs:137:20:137:27 | [0u8; 32] [element] | provenance | |
-| test_cipher.rs:138:9:138:18 | mut nonce4 [element] | test_cipher.rs:142:30:142:42 | nonce4.into(...) [element] | provenance | MaD:105 |
-| test_cipher.rs:138:22:138:29 | [0u8; 12] [element] | test_cipher.rs:138:9:138:18 | mut nonce4 [element] | provenance | |
-| test_cipher.rs:138:23:138:25 | 0u8 | test_cipher.rs:138:22:138:29 | [0u8; 12] [element] | provenance | |
-| test_cipher.rs:141:34:141:45 | &... [&ref, element] | test_cipher.rs:141:19:141:32 | ...::new | provenance | MaD:93 Sink:MaD:93 Sink:MaD:93 |
-| test_cipher.rs:141:35:141:45 | key4.into(...) [element] | test_cipher.rs:141:34:141:45 | &... [&ref, element] | provenance | |
-| test_cipher.rs:142:29:142:42 | &... [&ref, element] | test_cipher.rs:142:21:142:27 | encrypt | provenance | MaD:94 Sink:MaD:94 Sink:MaD:94 |
-| test_cipher.rs:142:30:142:42 | nonce4.into(...) [element] | test_cipher.rs:142:29:142:42 | &... [&ref, element] | provenance | |
nodes
| test_cipher.rs:18:9:18:14 | const1 [&ref, element] | semmle.label | const1 [&ref, element] |
| test_cipher.rs:18:28:18:36 | &... [&ref, element] | semmle.label | &... [&ref, element] |
@@ -223,16 +211,4 @@ nodes
| test_cipher.rs:133:21:133:27 | encrypt | semmle.label | encrypt |
| test_cipher.rs:133:29:133:42 | &... [&ref, element] | semmle.label | &... [&ref, element] |
| test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | semmle.label | nonce3.into(...) [element] |
-| test_cipher.rs:137:9:137:16 | mut key4 [element] | semmle.label | mut key4 [element] |
-| test_cipher.rs:137:20:137:27 | [0u8; 32] [element] | semmle.label | [0u8; 32] [element] |
-| test_cipher.rs:137:21:137:23 | 0u8 | semmle.label | 0u8 |
-| test_cipher.rs:138:9:138:18 | mut nonce4 [element] | semmle.label | mut nonce4 [element] |
-| test_cipher.rs:138:22:138:29 | [0u8; 12] [element] | semmle.label | [0u8; 12] [element] |
-| test_cipher.rs:138:23:138:25 | 0u8 | semmle.label | 0u8 |
-| test_cipher.rs:141:19:141:32 | ...::new | semmle.label | ...::new |
-| test_cipher.rs:141:34:141:45 | &... [&ref, element] | semmle.label | &... [&ref, element] |
-| test_cipher.rs:141:35:141:45 | key4.into(...) [element] | semmle.label | key4.into(...) [element] |
-| test_cipher.rs:142:21:142:27 | encrypt | semmle.label | encrypt |
-| test_cipher.rs:142:29:142:42 | &... [&ref, element] | semmle.label | &... [&ref, element] |
-| test_cipher.rs:142:30:142:42 | nonce4.into(...) [element] | semmle.label | nonce4.into(...) [element] |
subpaths
diff --git a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
index a72eaebb303..2bf36213176 100644
--- a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
+++ b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
@@ -134,10 +134,10 @@ fn test_aes_gcm(
// with barrier
- let mut key4 = [0u8;32]; // $ SPURIOUS: Alert[rust/hardcoded-cryptographic-value]
- let mut nonce4 = [0u8;12]; // $ SPURIOUS: Alert[rust/hardcoded-cryptographic-value]
+ let mut key4 = [0u8;32];
+ let mut nonce4 = [0u8;12];
_ = getrandom::fill(&mut key4).unwrap();
_ = getrandom2::getrandom(&mut nonce4).unwrap();
- let cipher4 = Aes256Gcm::new(&key4.into()); // $ Sink
- let _ = cipher2.encrypt(&nonce4.into(), b"plaintext".as_ref()).unwrap(); // $ Sink
+ let cipher4 = Aes256Gcm::new(&key4.into());
+ let _ = cipher2.encrypt(&nonce4.into(), b"plaintext".as_ref()).unwrap();
}
From 1ca5c593f9713f80973a52ee7d49055d568eb34d Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Mon, 10 Mar 2025 11:47:23 +0000
Subject: [PATCH 021/534] Rust: Replace imports of internal.DataFlowImpl where
possible.
---
.../ql/lib/codeql/rust/security/CleartextLoggingExtensions.qll | 2 +-
.../rust/security/HardcodedCryptographicValueExtensions.qll | 3 ++-
rust/ql/lib/codeql/rust/security/SqlInjectionExtensions.qll | 2 +-
rust/ql/src/queries/summary/Stats.qll | 1 -
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/rust/ql/lib/codeql/rust/security/CleartextLoggingExtensions.qll b/rust/ql/lib/codeql/rust/security/CleartextLoggingExtensions.qll
index bfe6da7ac82..a2e737627b5 100644
--- a/rust/ql/lib/codeql/rust/security/CleartextLoggingExtensions.qll
+++ b/rust/ql/lib/codeql/rust/security/CleartextLoggingExtensions.qll
@@ -5,7 +5,7 @@
import rust
private import codeql.rust.dataflow.DataFlow
-private import codeql.rust.dataflow.internal.DataFlowImpl
+private import codeql.rust.dataflow.FlowSink
private import codeql.rust.security.SensitiveData
/**
diff --git a/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll b/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
index b6ed9d6091e..5497cc0c99d 100644
--- a/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
+++ b/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
@@ -5,7 +5,8 @@
import rust
private import codeql.rust.dataflow.DataFlow
-private import codeql.rust.dataflow.internal.DataFlowImpl
+private import codeql.rust.dataflow.FlowSource
+private import codeql.rust.dataflow.FlowSink
private import codeql.rust.security.SensitiveData
/**
diff --git a/rust/ql/lib/codeql/rust/security/SqlInjectionExtensions.qll b/rust/ql/lib/codeql/rust/security/SqlInjectionExtensions.qll
index 4de71208004..78b87e4715b 100644
--- a/rust/ql/lib/codeql/rust/security/SqlInjectionExtensions.qll
+++ b/rust/ql/lib/codeql/rust/security/SqlInjectionExtensions.qll
@@ -6,7 +6,7 @@
import rust
private import codeql.rust.dataflow.DataFlow
-private import codeql.rust.dataflow.internal.DataFlowImpl
+private import codeql.rust.dataflow.FlowSink
private import codeql.rust.Concepts
private import codeql.util.Unit
diff --git a/rust/ql/src/queries/summary/Stats.qll b/rust/ql/src/queries/summary/Stats.qll
index 04c4bcf4e17..85e3357e680 100644
--- a/rust/ql/src/queries/summary/Stats.qll
+++ b/rust/ql/src/queries/summary/Stats.qll
@@ -4,7 +4,6 @@
import rust
private import codeql.rust.dataflow.DataFlow
-private import codeql.rust.dataflow.internal.DataFlowImpl
private import codeql.rust.dataflow.internal.TaintTrackingImpl
private import codeql.rust.internal.AstConsistency as AstConsistency
private import codeql.rust.controlflow.internal.CfgConsistency as CfgConsistency
From e3beacbda20020f53c883d28c3302d9e61032453 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Mon, 10 Mar 2025 19:35:59 +0000
Subject: [PATCH 022/534] Rust: Print models (temporary, to see how this
differs on CI).
---
.../HardcodedCryptographicValue.expected | 84 +++++++++++--------
.../CWE-798/HardcodedCryptographicValue.qlref | 4 +-
2 files changed, 52 insertions(+), 36 deletions(-)
diff --git a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
index 726934d5d98..86c2812d162 100644
--- a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
+++ b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.expected
@@ -19,78 +19,78 @@ edges
| test_cipher.rs:18:28:18:36 | &... [&ref, element] | test_cipher.rs:18:9:18:14 | const1 [&ref, element] | provenance | |
| test_cipher.rs:18:29:18:36 | [0u8; 16] [element] | test_cipher.rs:18:28:18:36 | &... [&ref, element] | provenance | |
| test_cipher.rs:18:30:18:32 | 0u8 | test_cipher.rs:18:29:18:36 | [0u8; 16] [element] | provenance | |
-| test_cipher.rs:19:49:19:79 | ...::from_slice(...) [&ref, element] | test_cipher.rs:19:30:19:47 | ...::new | provenance | MaD:61 Sink:MaD:61 Sink:MaD:61 |
-| test_cipher.rs:19:73:19:78 | const1 [&ref, element] | test_cipher.rs:19:49:19:79 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
+| test_cipher.rs:19:49:19:79 | ...::from_slice(...) [&ref, element] | test_cipher.rs:19:30:19:47 | ...::new | provenance | MaD:5 Sink:MaD:5 Sink:MaD:5 |
+| test_cipher.rs:19:73:19:78 | const1 [&ref, element] | test_cipher.rs:19:49:19:79 | ...::from_slice(...) [&ref, element] | provenance | MaD:13 |
| test_cipher.rs:25:9:25:14 | const4 [&ref, element] | test_cipher.rs:26:66:26:71 | const4 [&ref, element] | provenance | |
| test_cipher.rs:25:28:25:36 | &... [&ref, element] | test_cipher.rs:25:9:25:14 | const4 [&ref, element] | provenance | |
| test_cipher.rs:25:29:25:36 | [0u8; 16] [element] | test_cipher.rs:25:28:25:36 | &... [&ref, element] | provenance | |
| test_cipher.rs:25:30:25:32 | 0u8 | test_cipher.rs:25:29:25:36 | [0u8; 16] [element] | provenance | |
-| test_cipher.rs:26:42:26:72 | ...::from_slice(...) [&ref, element] | test_cipher.rs:26:30:26:40 | ...::new | provenance | MaD:61 Sink:MaD:61 Sink:MaD:61 |
-| test_cipher.rs:26:66:26:71 | const4 [&ref, element] | test_cipher.rs:26:42:26:72 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
+| test_cipher.rs:26:42:26:72 | ...::from_slice(...) [&ref, element] | test_cipher.rs:26:30:26:40 | ...::new | provenance | MaD:5 Sink:MaD:5 Sink:MaD:5 |
+| test_cipher.rs:26:66:26:71 | const4 [&ref, element] | test_cipher.rs:26:42:26:72 | ...::from_slice(...) [&ref, element] | provenance | MaD:13 |
| test_cipher.rs:29:9:29:14 | const5 [&ref, element] | test_cipher.rs:30:95:30:100 | const5 [&ref, element] | provenance | |
| test_cipher.rs:29:28:29:36 | &... [&ref, element] | test_cipher.rs:29:9:29:14 | const5 [&ref, element] | provenance | |
| test_cipher.rs:29:29:29:36 | [0u8; 16] [element] | test_cipher.rs:29:28:29:36 | &... [&ref, element] | provenance | |
| test_cipher.rs:29:30:29:32 | 0u8 | test_cipher.rs:29:29:29:36 | [0u8; 16] [element] | provenance | |
-| test_cipher.rs:30:72:30:101 | ...::from_slice(...) [&ref, element] | test_cipher.rs:30:30:30:40 | ...::new | provenance | MaD:62 Sink:MaD:62 Sink:MaD:62 |
-| test_cipher.rs:30:95:30:100 | const5 [&ref, element] | test_cipher.rs:30:72:30:101 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
+| test_cipher.rs:30:72:30:101 | ...::from_slice(...) [&ref, element] | test_cipher.rs:30:30:30:40 | ...::new | provenance | MaD:4 Sink:MaD:4 Sink:MaD:4 |
+| test_cipher.rs:30:95:30:100 | const5 [&ref, element] | test_cipher.rs:30:72:30:101 | ...::from_slice(...) [&ref, element] | provenance | MaD:13 |
| test_cipher.rs:37:9:37:14 | const7 | test_cipher.rs:38:74:38:79 | const7 | provenance | |
| test_cipher.rs:37:27:37:74 | [...] | test_cipher.rs:37:9:37:14 | const7 | provenance | |
-| test_cipher.rs:38:49:38:80 | ...::from_slice(...) [&ref] | test_cipher.rs:38:30:38:47 | ...::new | provenance | MaD:61 Sink:MaD:61 |
-| test_cipher.rs:38:73:38:79 | &const7 [&ref] | test_cipher.rs:38:49:38:80 | ...::from_slice(...) [&ref] | provenance | MaD:0 |
+| test_cipher.rs:38:49:38:80 | ...::from_slice(...) [&ref] | test_cipher.rs:38:30:38:47 | ...::new | provenance | MaD:5 Sink:MaD:5 |
+| test_cipher.rs:38:73:38:79 | &const7 [&ref] | test_cipher.rs:38:49:38:80 | ...::from_slice(...) [&ref] | provenance | MaD:13 |
| test_cipher.rs:38:74:38:79 | const7 | test_cipher.rs:38:73:38:79 | &const7 [&ref] | provenance | |
| test_cipher.rs:41:9:41:14 | const8 [&ref] | test_cipher.rs:42:73:42:78 | const8 [&ref] | provenance | |
| test_cipher.rs:41:28:41:76 | &... [&ref] | test_cipher.rs:41:9:41:14 | const8 [&ref] | provenance | |
| test_cipher.rs:41:29:41:76 | [...] | test_cipher.rs:41:28:41:76 | &... [&ref] | provenance | |
-| test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref] | test_cipher.rs:42:30:42:47 | ...::new | provenance | MaD:61 Sink:MaD:61 |
-| test_cipher.rs:42:73:42:78 | const8 [&ref] | test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref] | provenance | MaD:0 |
-| test_cipher.rs:45:9:45:14 | const9 | test_cipher.rs:46:32:46:54 | const9.align_to(...) [tuple.1, &ref, element] | provenance | MaD:107 |
+| test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref] | test_cipher.rs:42:30:42:47 | ...::new | provenance | MaD:5 Sink:MaD:5 |
+| test_cipher.rs:42:73:42:78 | const8 [&ref] | test_cipher.rs:42:49:42:79 | ...::from_slice(...) [&ref] | provenance | MaD:13 |
+| test_cipher.rs:45:9:45:14 | const9 | test_cipher.rs:46:32:46:54 | const9.align_to(...) [tuple.1, &ref, element] | provenance | MaD:10 |
| test_cipher.rs:45:27:45:50 | [...] | test_cipher.rs:45:9:45:14 | const9 | provenance | |
| test_cipher.rs:46:9:46:19 | const9_conv [&ref, element] | test_cipher.rs:47:73:47:83 | const9_conv [&ref, element] | provenance | |
| test_cipher.rs:46:32:46:54 | const9.align_to(...) [tuple.1, &ref, element] | test_cipher.rs:46:32:46:56 | ... .1 [&ref, element] | provenance | |
| test_cipher.rs:46:32:46:56 | ... .1 [&ref, element] | test_cipher.rs:46:9:46:19 | const9_conv [&ref, element] | provenance | |
-| test_cipher.rs:47:49:47:84 | ...::from_slice(...) [&ref, element] | test_cipher.rs:47:30:47:47 | ...::new | provenance | MaD:61 Sink:MaD:61 Sink:MaD:61 |
-| test_cipher.rs:47:73:47:83 | const9_conv [&ref, element] | test_cipher.rs:47:49:47:84 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
+| test_cipher.rs:47:49:47:84 | ...::from_slice(...) [&ref, element] | test_cipher.rs:47:30:47:47 | ...::new | provenance | MaD:5 Sink:MaD:5 Sink:MaD:5 |
+| test_cipher.rs:47:73:47:83 | const9_conv [&ref, element] | test_cipher.rs:47:49:47:84 | ...::from_slice(...) [&ref, element] | provenance | MaD:13 |
| test_cipher.rs:50:9:50:15 | const10 [element] | test_cipher.rs:51:75:51:81 | const10 [element] | provenance | |
-| test_cipher.rs:50:37:50:52 | ...::zeroed | test_cipher.rs:50:37:50:54 | ...::zeroed(...) [element] | provenance | Src:MaD:104 |
+| test_cipher.rs:50:37:50:52 | ...::zeroed | test_cipher.rs:50:37:50:54 | ...::zeroed(...) [element] | provenance | Src:MaD:9 |
| test_cipher.rs:50:37:50:54 | ...::zeroed(...) [element] | test_cipher.rs:50:9:50:15 | const10 [element] | provenance | |
-| test_cipher.rs:51:50:51:82 | ...::from_slice(...) [&ref, element] | test_cipher.rs:51:31:51:48 | ...::new | provenance | MaD:61 Sink:MaD:61 Sink:MaD:61 |
-| test_cipher.rs:51:74:51:81 | &const10 [&ref, element] | test_cipher.rs:51:50:51:82 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
+| test_cipher.rs:51:50:51:82 | ...::from_slice(...) [&ref, element] | test_cipher.rs:51:31:51:48 | ...::new | provenance | MaD:5 Sink:MaD:5 Sink:MaD:5 |
+| test_cipher.rs:51:74:51:81 | &const10 [&ref, element] | test_cipher.rs:51:50:51:82 | ...::from_slice(...) [&ref, element] | provenance | MaD:13 |
| test_cipher.rs:51:75:51:81 | const10 [element] | test_cipher.rs:51:74:51:81 | &const10 [&ref, element] | provenance | |
| test_cipher.rs:66:9:66:14 | const2 [&ref, element] | test_cipher.rs:67:35:67:40 | const2 [&ref, element] | provenance | |
-| test_cipher.rs:66:9:66:14 | const2 [&ref, element] | test_cipher.rs:67:35:67:47 | const2.into(...) [element] | provenance | MaD:106 |
+| test_cipher.rs:66:9:66:14 | const2 [&ref, element] | test_cipher.rs:67:35:67:47 | const2.into(...) [element] | provenance | MaD:12 |
| test_cipher.rs:66:18:66:26 | &... [&ref, element] | test_cipher.rs:66:9:66:14 | const2 [&ref, element] | provenance | |
| test_cipher.rs:66:19:66:26 | [0u8; 32] [element] | test_cipher.rs:66:18:66:26 | &... [&ref, element] | provenance | |
| test_cipher.rs:66:20:66:22 | 0u8 | test_cipher.rs:66:19:66:26 | [0u8; 32] [element] | provenance | |
-| test_cipher.rs:67:35:67:40 | const2 [&ref, element] | test_cipher.rs:67:35:67:47 | const2.into(...) [element] | provenance | MaD:105 |
-| test_cipher.rs:67:35:67:47 | const2.into(...) [element] | test_cipher.rs:67:23:67:33 | ...::new | provenance | MaD:77 Sink:MaD:77 |
+| test_cipher.rs:67:35:67:40 | const2 [&ref, element] | test_cipher.rs:67:35:67:47 | const2.into(...) [element] | provenance | MaD:11 |
+| test_cipher.rs:67:35:67:47 | const2.into(...) [element] | test_cipher.rs:67:23:67:33 | ...::new | provenance | MaD:2 Sink:MaD:2 |
| test_cipher.rs:73:9:73:14 | const2 [&ref, element] | test_cipher.rs:74:46:74:51 | const2 [&ref, element] | provenance | |
| test_cipher.rs:73:18:73:26 | &... [&ref, element] | test_cipher.rs:73:9:73:14 | const2 [&ref, element] | provenance | |
| test_cipher.rs:73:19:73:26 | [0u8; 32] [element] | test_cipher.rs:73:18:73:26 | &... [&ref, element] | provenance | |
| test_cipher.rs:73:20:73:22 | 0u8 | test_cipher.rs:73:19:73:26 | [0u8; 32] [element] | provenance | |
-| test_cipher.rs:74:46:74:51 | const2 [&ref, element] | test_cipher.rs:74:23:74:44 | ...::new_from_slice | provenance | MaD:87 Sink:MaD:87 Sink:MaD:87 |
+| test_cipher.rs:74:46:74:51 | const2 [&ref, element] | test_cipher.rs:74:23:74:44 | ...::new_from_slice | provenance | MaD:8 Sink:MaD:8 Sink:MaD:8 |
| test_cipher.rs:80:9:80:14 | const6 [&ref, element] | test_cipher.rs:81:63:81:68 | const6 [&ref, element] | provenance | |
-| test_cipher.rs:80:9:80:14 | const6 [&ref, element] | test_cipher.rs:81:63:81:75 | const6.into(...) [element] | provenance | MaD:106 |
+| test_cipher.rs:80:9:80:14 | const6 [&ref, element] | test_cipher.rs:81:63:81:75 | const6.into(...) [element] | provenance | MaD:12 |
| test_cipher.rs:80:18:80:26 | &... [&ref, element] | test_cipher.rs:80:9:80:14 | const6 [&ref, element] | provenance | |
| test_cipher.rs:80:19:80:26 | [0u8; 32] [element] | test_cipher.rs:80:18:80:26 | &... [&ref, element] | provenance | |
| test_cipher.rs:80:20:80:22 | 0u8 | test_cipher.rs:80:19:80:26 | [0u8; 32] [element] | provenance | |
-| test_cipher.rs:81:63:81:68 | const6 [&ref, element] | test_cipher.rs:81:63:81:75 | const6.into(...) [element] | provenance | MaD:105 |
-| test_cipher.rs:81:63:81:75 | const6.into(...) [element] | test_cipher.rs:81:23:81:61 | ...::new | provenance | MaD:89 Sink:MaD:89 |
+| test_cipher.rs:81:63:81:68 | const6 [&ref, element] | test_cipher.rs:81:63:81:75 | const6.into(...) [element] | provenance | MaD:11 |
+| test_cipher.rs:81:63:81:75 | const6.into(...) [element] | test_cipher.rs:81:23:81:61 | ...::new | provenance | MaD:7 Sink:MaD:7 |
| test_cipher.rs:84:9:84:14 | const7 [&ref, element] | test_cipher.rs:85:75:85:80 | const7 [&ref, element] | provenance | |
-| test_cipher.rs:84:9:84:14 | const7 [&ref, element] | test_cipher.rs:85:75:85:87 | const7.into(...) [element] | provenance | MaD:106 |
+| test_cipher.rs:84:9:84:14 | const7 [&ref, element] | test_cipher.rs:85:75:85:87 | const7.into(...) [element] | provenance | MaD:12 |
| test_cipher.rs:84:18:84:27 | &... [&ref, element] | test_cipher.rs:84:9:84:14 | const7 [&ref, element] | provenance | |
| test_cipher.rs:84:19:84:27 | [0u8; 16] [element] | test_cipher.rs:84:18:84:27 | &... [&ref, element] | provenance | |
| test_cipher.rs:84:20:84:22 | 0u8 | test_cipher.rs:84:19:84:27 | [0u8; 16] [element] | provenance | |
-| test_cipher.rs:85:75:85:80 | const7 [&ref, element] | test_cipher.rs:85:75:85:87 | const7.into(...) [element] | provenance | MaD:105 |
-| test_cipher.rs:85:75:85:87 | const7.into(...) [element] | test_cipher.rs:85:23:85:61 | ...::new | provenance | MaD:90 Sink:MaD:90 |
-| test_cipher.rs:124:9:124:12 | key2 [element] | test_cipher.rs:126:35:126:45 | key2.into(...) [element] | provenance | MaD:105 |
+| test_cipher.rs:85:75:85:80 | const7 [&ref, element] | test_cipher.rs:85:75:85:87 | const7.into(...) [element] | provenance | MaD:11 |
+| test_cipher.rs:85:75:85:87 | const7.into(...) [element] | test_cipher.rs:85:23:85:61 | ...::new | provenance | MaD:6 Sink:MaD:6 |
+| test_cipher.rs:124:9:124:12 | key2 [element] | test_cipher.rs:126:35:126:45 | key2.into(...) [element] | provenance | MaD:11 |
| test_cipher.rs:124:25:124:30 | [0; 32] [element] | test_cipher.rs:124:9:124:12 | key2 [element] | provenance | |
| test_cipher.rs:124:26:124:26 | 0 | test_cipher.rs:124:25:124:30 | [0; 32] [element] | provenance | |
-| test_cipher.rs:125:9:125:14 | nonce2 [element] | test_cipher.rs:127:30:127:42 | nonce2.into(...) [element] | provenance | MaD:105 |
+| test_cipher.rs:125:9:125:14 | nonce2 [element] | test_cipher.rs:127:30:127:42 | nonce2.into(...) [element] | provenance | MaD:11 |
| test_cipher.rs:125:18:125:23 | [0; 12] [element] | test_cipher.rs:125:9:125:14 | nonce2 [element] | provenance | |
| test_cipher.rs:125:19:125:19 | 0 | test_cipher.rs:125:18:125:23 | [0; 12] [element] | provenance | |
-| test_cipher.rs:126:34:126:45 | &... [&ref, element] | test_cipher.rs:126:19:126:32 | ...::new | provenance | MaD:93 Sink:MaD:93 Sink:MaD:93 |
+| test_cipher.rs:126:34:126:45 | &... [&ref, element] | test_cipher.rs:126:19:126:32 | ...::new | provenance | MaD:1 Sink:MaD:1 Sink:MaD:1 |
| test_cipher.rs:126:35:126:45 | key2.into(...) [element] | test_cipher.rs:126:34:126:45 | &... [&ref, element] | provenance | |
-| test_cipher.rs:127:29:127:42 | &... [&ref, element] | test_cipher.rs:127:21:127:27 | encrypt | provenance | MaD:94 Sink:MaD:94 Sink:MaD:94 |
+| test_cipher.rs:127:29:127:42 | &... [&ref, element] | test_cipher.rs:127:21:127:27 | encrypt | provenance | MaD:3 Sink:MaD:3 Sink:MaD:3 |
| test_cipher.rs:127:30:127:42 | nonce2.into(...) [element] | test_cipher.rs:127:29:127:42 | &... [&ref, element] | provenance | |
| test_cipher.rs:129:9:129:18 | key3_array [&ref, element] | test_cipher.rs:130:45:130:54 | key3_array [&ref, element] | provenance | |
| test_cipher.rs:129:32:129:41 | &... [&ref, element] | test_cipher.rs:129:9:129:18 | key3_array [&ref, element] | provenance | |
@@ -98,15 +98,29 @@ edges
| test_cipher.rs:129:34:129:37 | 0xff | test_cipher.rs:129:33:129:41 | [0xff; 32] [element] | provenance | |
| test_cipher.rs:130:9:130:12 | key3 [&ref, element] | test_cipher.rs:132:35:132:38 | key3 [&ref, element] | provenance | |
| test_cipher.rs:130:16:130:55 | ...::from_slice(...) [&ref, element] | test_cipher.rs:130:9:130:12 | key3 [&ref, element] | provenance | |
-| test_cipher.rs:130:45:130:54 | key3_array [&ref, element] | test_cipher.rs:130:16:130:55 | ...::from_slice(...) [&ref, element] | provenance | MaD:0 |
-| test_cipher.rs:131:9:131:14 | nonce3 [element] | test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | provenance | MaD:105 |
+| test_cipher.rs:130:45:130:54 | key3_array [&ref, element] | test_cipher.rs:130:16:130:55 | ...::from_slice(...) [&ref, element] | provenance | MaD:13 |
+| test_cipher.rs:131:9:131:14 | nonce3 [element] | test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | provenance | MaD:11 |
| test_cipher.rs:131:27:131:35 | [0xff; 12] [element] | test_cipher.rs:131:9:131:14 | nonce3 [element] | provenance | |
| test_cipher.rs:131:28:131:31 | 0xff | test_cipher.rs:131:27:131:35 | [0xff; 12] [element] | provenance | |
-| test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | test_cipher.rs:132:19:132:32 | ...::new | provenance | MaD:93 Sink:MaD:93 Sink:MaD:93 |
-| test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | test_cipher.rs:132:19:132:32 | ...::new | provenance | MaD:93 Sink:MaD:93 Sink:MaD:93 Sink:MaD:93 |
+| test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | test_cipher.rs:132:19:132:32 | ...::new | provenance | MaD:1 Sink:MaD:1 Sink:MaD:1 |
+| test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | test_cipher.rs:132:19:132:32 | ...::new | provenance | MaD:1 Sink:MaD:1 Sink:MaD:1 Sink:MaD:1 |
| test_cipher.rs:132:35:132:38 | key3 [&ref, element] | test_cipher.rs:132:34:132:38 | &key3 [&ref, &ref, element] | provenance | |
-| test_cipher.rs:133:29:133:42 | &... [&ref, element] | test_cipher.rs:133:21:133:27 | encrypt | provenance | MaD:94 Sink:MaD:94 Sink:MaD:94 |
+| test_cipher.rs:133:29:133:42 | &... [&ref, element] | test_cipher.rs:133:21:133:27 | encrypt | provenance | MaD:3 Sink:MaD:3 Sink:MaD:3 |
| test_cipher.rs:133:30:133:42 | nonce3.into(...) [element] | test_cipher.rs:133:29:133:42 | &... [&ref, element] | provenance | |
+models
+| 1 | Sink: repo:https://github.com/RustCrypto/AEADs:aes-gcm; ::new; credentials-key; Argument[0] |
+| 2 | Sink: repo:https://github.com/RustCrypto/block-ciphers:aes; ::new; credentials-key; Argument[0] |
+| 3 | Sink: repo:https://github.com/RustCrypto/traits:aead; <_ as crate::Aead>::encrypt; credentials-nonce; Argument[0] |
+| 4 | Sink: repo:https://github.com/RustCrypto/traits:cipher; ::new; credentials-iv; Argument[1] |
+| 5 | Sink: repo:https://github.com/RustCrypto/traits:cipher; ::new; credentials-key; Argument[0] |
+| 6 | Sink: repo:https://github.com/RustCrypto/traits:crypto-common; <_ as crate::KeyIvInit>::new; credentials-iv; Argument[1] |
+| 7 | Sink: repo:https://github.com/RustCrypto/traits:crypto-common; <_ as crate::KeyIvInit>::new; credentials-key; Argument[0] |
+| 8 | Sink: repo:https://github.com/RustCrypto/traits:crypto-common; crate::KeyInit::new_from_slice; credentials-key; Argument[0] |
+| 9 | Source: lang:core; crate::mem::zeroed; constant-source; ReturnValue.Element |
+| 10 | Summary: lang:core; <[_]>::align_to; Argument[self].Element; ReturnValue.Field[0,1,2].Reference.Element; taint |
+| 11 | Summary: lang:core; <_ as crate::convert::Into>::into; Argument[self].Element; ReturnValue.Element; taint |
+| 12 | Summary: lang:core; <_ as crate::convert::Into>::into; Argument[self].Reference.Element; ReturnValue.Element; taint |
+| 13 | Summary: repo:https://github.com/fizyk20/generic-array.git:generic-array; ::from_slice; Argument[0].Reference; ReturnValue.Reference; value |
nodes
| test_cipher.rs:18:9:18:14 | const1 [&ref, element] | semmle.label | const1 [&ref, element] |
| test_cipher.rs:18:28:18:36 | &... [&ref, element] | semmle.label | &... [&ref, element] |
diff --git a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.qlref b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.qlref
index 99053e9bf1a..77c0b90160c 100644
--- a/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.qlref
+++ b/rust/ql/test/query-tests/security/CWE-798/HardcodedCryptographicValue.qlref
@@ -1,2 +1,4 @@
query: queries/security/CWE-798/HardcodedCryptographicValue.ql
-postprocess: utils/test/InlineExpectationsTestQuery.ql
+postprocess:
+ - utils/test/PrettyPrintModels.ql
+ - utils/test/InlineExpectationsTestQuery.ql
From a0f4fa28b2a50a077c380646bb2828da85b3426d Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Tue, 11 Mar 2025 09:30:01 +0000
Subject: [PATCH 023/534] Rust: hardcoded -> hard-coded.
---
.../HardcodedCryptographicValueExtensions.qll | 12 +++----
.../CWE-798/HardcodedCryptographicValue.qhelp | 14 ++++----
.../CWE-798/HardcodedCryptographicValue.ql | 6 ++--
.../CWE-798/HardcodedCryptographicValueBad.rs | 2 +-
.../security/CWE-798/test_cipher.rs | 36 +++++++++----------
5 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll b/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
index 5497cc0c99d..80fdcfd217e 100644
--- a/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
+++ b/rust/ql/lib/codeql/rust/security/HardcodedCryptographicValueExtensions.qll
@@ -1,5 +1,5 @@
/**
- * Provides classes and predicates for reasoning about hardcoded cryptographic value
+ * Provides classes and predicates for reasoning about hard-coded cryptographic value
* vulnerabilities.
*/
@@ -32,17 +32,17 @@ class CryptographicValueKind extends string {
}
/**
- * Provides default sources, sinks and barriers for detecting hardcoded cryptographic
+ * Provides default sources, sinks and barriers for detecting hard-coded cryptographic
* value vulnerabilities, as well as extension points for adding your own.
*/
module HardcodedCryptographicValue {
/**
- * A data flow source for hardcoded cryptographic value vulnerabilities.
+ * A data flow source for hard-coded cryptographic value vulnerabilities.
*/
abstract class Source extends DataFlow::Node { }
/**
- * A data flow sink for hardcoded cryptographic value vulnerabilities.
+ * A data flow sink for hard-coded cryptographic value vulnerabilities.
*/
abstract class Sink extends DataFlow::Node {
/**
@@ -52,7 +52,7 @@ module HardcodedCryptographicValue {
}
/**
- * A barrier for hardcoded cryptographic value vulnerabilities.
+ * A barrier for hard-coded cryptographic value vulnerabilities.
*/
abstract class Barrier extends DataFlow::Node { }
@@ -81,7 +81,7 @@ module HardcodedCryptographicValue {
}
/**
- * An externally modeled sink for hardcoded cryptographic value vulnerabilities.
+ * An externally modeled sink for hard-coded cryptographic value vulnerabilities.
*/
private class ModelsAsDataSinks extends Sink {
CryptographicValueKind kind;
diff --git a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.qhelp b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.qhelp
index f3b2d831944..3a6813cdef0 100644
--- a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.qhelp
+++ b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.qhelp
@@ -5,17 +5,17 @@
-Hardcoded passwords, keys, initialization vectors, and salts should not be used for cryptographic operations.
+Hard-coded passwords, keys, initialization vectors, and salts should not be used for cryptographic operations.
-
- Attackers can easily recover hardcoded values if they have access to the source code or compiled executable.
+ Attackers can easily recover hard-coded values if they have access to the source code or compiled executable.
-
- Some hardcoded values are easily guessable.
+ Some hard-coded values are easily guessable.
-
- Use of hardcoded values may leave cryptographic operations vulnerable to dictionary attacks, rainbow tables, and other forms of cryptanalysis.
+ Use of hard-coded values may leave cryptographic operations vulnerable to dictionary attacks, rainbow tables, and other forms of cryptanalysis.
@@ -23,20 +23,20 @@ Hardcoded passwords, keys, initialization vectors, and salts should not be used
-Use randomly generated key material, initialization vectors, and salts. Use strong passwords that are not hardcoded.
+Use randomly generated key material, initialization vectors, and salts. Use strong passwords that are not hard-coded.
-The following example shows instantiating a cipher with hardcoded key material, making the encrypted data vulnerable to recovery.
+The following example shows instantiating a cipher with hard-coded key material, making the encrypted data vulnerable to recovery.
-In the fixed code below, the key material is randomly generated and not hardcoded, which protects the encrypted data against recovery. A real application would also need a strategy for secure key management after the key has been generated.
+In the fixed code below, the key material is randomly generated and not hard-coded, which protects the encrypted data against recovery. A real application would also need a strategy for secure key management after the key has been generated.
diff --git a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
index 3fb9d4d74a2..fee36ba2ab2 100644
--- a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
+++ b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
@@ -1,12 +1,12 @@
/**
* @name Hard-coded cryptographic value
- * @description Using hardcoded keys, passwords, salts or initialization
+ * @description Using hard-coded keys, passwords, salts or initialization
* vectors is not secure.
* @kind path-problem
* @problem.severity warning
* @security-severity 9.8
* @precision high
- * @id rust/hardcoded-cryptographic-value
+ * @id rust/hard-coded-cryptographic-value
* @tags security
* external/cwe/cwe-259
* external/cwe/cwe-321
@@ -21,7 +21,7 @@ import codeql.rust.dataflow.TaintTracking
import codeql.rust.dataflow.internal.DataFlowImpl
/**
- * A taint-tracking configuration for hardcoded cryptographic value vulnerabilities.
+ * A taint-tracking configuration for hard-coded cryptographic value vulnerabilities.
*/
module HardcodedCryptographicValueConfig implements DataFlow::ConfigSig {
import HardcodedCryptographicValue
diff --git a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValueBad.rs b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValueBad.rs
index c1923df1730..11dacfc08c4 100644
--- a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValueBad.rs
+++ b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValueBad.rs
@@ -1,2 +1,2 @@
-let key: [u8;32] = [0;32]; // BAD: Using hardcoded keys for encryption
+let key: [u8;32] = [0;32]; // BAD: Using hard-coded keys for encryption
let cipher = Aes256Gcm::new(&key.into());
diff --git a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
index 2bf36213176..fc7a464e70c 100644
--- a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
+++ b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
@@ -15,18 +15,18 @@ fn test_stream_cipher_rabbit(
let mut rabbit_cipher1 = RabbitKeyOnly::new(rabbit::Key::from_slice(key));
rabbit_cipher1.apply_keystream(&mut data);
- let const1: &[u8;16] = &[0u8;16]; // $ Alert[rust/hardcoded-cryptographic-value]
+ let const1: &[u8;16] = &[0u8;16]; // $ Alert[rust/hard-coded-cryptographic-value]
let mut rabbit_cipher2 = RabbitKeyOnly::new(rabbit::Key::from_slice(const1)); // $ Sink
rabbit_cipher2.apply_keystream(&mut data);
let mut rabbit_cipher3 = Rabbit::new(rabbit::Key::from_slice(key), rabbit::Iv::from_slice(iv));
rabbit_cipher3.apply_keystream(&mut data);
- let const4: &[u8;16] = &[0u8;16]; // $ Alert[rust/hardcoded-cryptographic-value]
+ let const4: &[u8;16] = &[0u8;16]; // $ Alert[rust/hard-coded-cryptographic-value]
let mut rabbit_cipher4 = Rabbit::new(rabbit::Key::from_slice(const4), rabbit::Iv::from_slice(iv)); // $ Sink
rabbit_cipher4.apply_keystream(&mut data);
- let const5: &[u8;16] = &[0u8;16]; // $ Alert[rust/hardcoded-cryptographic-value]
+ let const5: &[u8;16] = &[0u8;16]; // $ Alert[rust/hard-coded-cryptographic-value]
let mut rabbit_cipher5 = Rabbit::new(rabbit::Key::from_slice(key), rabbit::Iv::from_slice(const5)); // $ Sink
rabbit_cipher5.apply_keystream(&mut data);
@@ -34,20 +34,20 @@ fn test_stream_cipher_rabbit(
let const6: &[u8;16] = &[0u8;16]; // (unused, so good)
- let const7: [u8;16] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // $ Alert[rust/hardcoded-cryptographic-value]
+ let const7: [u8;16] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // $ Alert[rust/hard-coded-cryptographic-value]
let mut rabbit_cipher7 = RabbitKeyOnly::new(rabbit::Key::from_slice(&const7)); // $ Sink
rabbit_cipher7.apply_keystream(&mut data);
- let const8: &[u8;16] = &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // $ Alert[rust/hardcoded-cryptographic-value]
+ let const8: &[u8;16] = &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; // $ Alert[rust/hard-coded-cryptographic-value]
let mut rabbit_cipher8 = RabbitKeyOnly::new(rabbit::Key::from_slice(const8)); // $ Sink
rabbit_cipher8.apply_keystream(&mut data);
- let const9: [u16;8] = [0, 0, 0, 0, 0, 0, 0, 0]; // $ Alert[rust/hardcoded-cryptographic-value]
+ let const9: [u16;8] = [0, 0, 0, 0, 0, 0, 0, 0]; // $ Alert[rust/hard-coded-cryptographic-value]
let const9_conv = unsafe { const9.align_to::().1 }; // convert [u16;8] -> [u8;8]
let mut rabbit_cipher9 = RabbitKeyOnly::new(rabbit::Key::from_slice(const9_conv)); // $ Sink
rabbit_cipher9.apply_keystream(&mut data);
- let const10: [u8;16] = unsafe { std::mem::zeroed() }; // $ Alert[rust/hardcoded-cryptographic-value]
+ let const10: [u8;16] = unsafe { std::mem::zeroed() }; // $ Alert[rust/hard-coded-cryptographic-value]
let mut rabbit_cipher10 = RabbitKeyOnly::new(rabbit::Key::from_slice(&const10)); // $ Sink
rabbit_cipher10.apply_keystream(&mut data);
}
@@ -63,25 +63,25 @@ fn test_block_cipher_aes(
let aes_cipher1 = Aes256::new(key256.into());
aes_cipher1.encrypt_block(block128.into());
- let const2 = &[0u8;32]; // $ Alert[rust/hardcoded-cryptographic-value]
+ let const2 = &[0u8;32]; // $ Alert[rust/hard-coded-cryptographic-value]
let aes_cipher2 = Aes256::new(const2.into()); // $ Sink
aes_cipher2.encrypt_block(block128.into());
let aes_cipher3 = Aes256::new_from_slice(key256).unwrap();
aes_cipher3.encrypt_block(block128.into());
- let const2 = &[0u8;32]; // $ Alert[rust/hardcoded-cryptographic-value]
+ let const2 = &[0u8;32]; // $ Alert[rust/hard-coded-cryptographic-value]
let aes_cipher4 = Aes256::new_from_slice(const2).unwrap(); // $ Sink
aes_cipher4.encrypt_block(block128.into());
let aes_cipher5 = cfb_mode::Encryptor::::new(key.into(), iv.into());
_ = aes_cipher5.encrypt_b2b(input, output).unwrap();
- let const6 = &[0u8;32]; // $ Alert[rust/hardcoded-cryptographic-value]
+ let const6 = &[0u8;32]; // $ Alert[rust/hard-coded-cryptographic-value]
let aes_cipher6 = cfb_mode::Encryptor::::new(const6.into(), iv.into()); // $ Sink
_ = aes_cipher6.encrypt_b2b(input, output).unwrap();
- let const7 = &[0u8; 16]; // $ Alert[rust/hardcoded-cryptographic-value]
+ let const7 = &[0u8; 16]; // $ Alert[rust/hard-coded-cryptographic-value]
let aes_cipher7 = cfb_mode::Encryptor::::new(key.into(), const7.into()); // $ Sink
_ = aes_cipher7.encrypt_b2b(input, output).unwrap();
@@ -91,18 +91,18 @@ fn test_block_cipher_aes(
let aes_cipher8 = cfb_mode::Encryptor::::new(key8.into(), iv.into());
_ = aes_cipher8.encrypt_b2b(input, output).unwrap();
- let key9: &[u8] = "1234567890123456".as_bytes(); // $ MISSING: Alert[rust/hardcoded-cryptographic-value]
+ let key9: &[u8] = "1234567890123456".as_bytes(); // $ MISSING: Alert[rust/hard-coded-cryptographic-value]
let aes_cipher9 = cfb_mode::Encryptor::::new(key9.into(), iv.into());
_ = aes_cipher9.encrypt_b2b(input, output).unwrap();
let key10: [u8; 32] = match base64::engine::general_purpose::STANDARD.decode(key_str) {
Ok(x) => x.try_into().unwrap(),
- Err(_) => "1234567890123456".as_bytes().try_into().unwrap() // $ MISSING: Alert[rust/hardcoded-cryptographic-value]
+ Err(_) => "1234567890123456".as_bytes().try_into().unwrap() // $ MISSING: Alert[rust/hard-coded-cryptographic-value]
};
let aes_cipher10 = Aes256::new(&key10.into());
aes_cipher10.encrypt_block(block128.into());
- if let Ok(const11) = base64::engine::general_purpose::STANDARD.decode("1234567890123456") { // $ MISSING: Alert[rust/hardcoded-cryptographic-value]
+ if let Ok(const11) = base64::engine::general_purpose::STANDARD.decode("1234567890123456") { // $ MISSING: Alert[rust/hard-coded-cryptographic-value]
let key11: [u8; 32] = const11.try_into().unwrap();
let aes_cipher11 = Aes256::new(&key11.into());
aes_cipher11.encrypt_block(block128.into());
@@ -121,14 +121,14 @@ fn test_aes_gcm(
let cipher1 = Aes256Gcm::new(&key1);
let _ = cipher1.encrypt(&nonce1, b"plaintext".as_ref()).unwrap();
- let key2: [u8;32] = [0;32]; // $ Alert[rust/hardcoded-cryptographic-value]
- let nonce2 = [0;12]; // $ Alert[rust/hardcoded-cryptographic-value]
+ let key2: [u8;32] = [0;32]; // $ Alert[rust/hard-coded-cryptographic-value]
+ let nonce2 = [0;12]; // $ Alert[rust/hard-coded-cryptographic-value]
let cipher2 = Aes256Gcm::new(&key2.into()); // $ Sink
let _ = cipher2.encrypt(&nonce2.into(), b"plaintext".as_ref()).unwrap(); // $ Sink
- let key3_array: &[u8;32] = &[0xff;32]; // $ Alert[rust/hardcoded-cryptographic-value]
+ let key3_array: &[u8;32] = &[0xff;32]; // $ Alert[rust/hard-coded-cryptographic-value]
let key3 = Key::::from_slice(key3_array);
- let nonce3: [u8;12] = [0xff;12]; // $ Alert[rust/hardcoded-cryptographic-value]
+ let nonce3: [u8;12] = [0xff;12]; // $ Alert[rust/hard-coded-cryptographic-value]
let cipher3 = Aes256Gcm::new(&key3); // $ Sink
let _ = cipher3.encrypt(&nonce3.into(), b"plaintext".as_ref()).unwrap(); // $ Sink
From 704b3850f42d5b3750238464ccbd468d37d0af46 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Mon, 17 Mar 2025 11:24:58 +0000
Subject: [PATCH 024/534] Rust: Fix a mistake in the test.
---
rust/ql/test/query-tests/security/CWE-798/test_cipher.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
index fc7a464e70c..79dfbabbd98 100644
--- a/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
+++ b/rust/ql/test/query-tests/security/CWE-798/test_cipher.rs
@@ -139,5 +139,5 @@ fn test_aes_gcm(
_ = getrandom::fill(&mut key4).unwrap();
_ = getrandom2::getrandom(&mut nonce4).unwrap();
let cipher4 = Aes256Gcm::new(&key4.into());
- let _ = cipher2.encrypt(&nonce4.into(), b"plaintext".as_ref()).unwrap();
+ let _ = cipher4.encrypt(&nonce4.into(), b"plaintext".as_ref()).unwrap();
}
From f5daec9da0fef7b56a2b0f4df6bd2e0b59079495 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Mon, 17 Mar 2025 12:10:59 +0000
Subject: [PATCH 025/534] Rust: Fix after merge.
---
.../src/queries/security/CWE-798/HardcodedCryptographicValue.ql | 1 +
1 file changed, 1 insertion(+)
diff --git a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
index fee36ba2ab2..cd0dca79119 100644
--- a/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
+++ b/rust/ql/src/queries/security/CWE-798/HardcodedCryptographicValue.ql
@@ -19,6 +19,7 @@ import codeql.rust.security.HardcodedCryptographicValueExtensions
import codeql.rust.dataflow.DataFlow
import codeql.rust.dataflow.TaintTracking
import codeql.rust.dataflow.internal.DataFlowImpl
+import codeql.rust.dataflow.internal.Content
/**
* A taint-tracking configuration for hard-coded cryptographic value vulnerabilities.
From 07011f74601fd7fc54848a1ac53534f43ba56ca8 Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Mon, 17 Mar 2025 12:22:09 +0000
Subject: [PATCH 026/534] Rust: Fix more after merge.
---
rust/ql/src/queries/summary/Stats.qll | 3 ---
1 file changed, 3 deletions(-)
diff --git a/rust/ql/src/queries/summary/Stats.qll b/rust/ql/src/queries/summary/Stats.qll
index c1914f68ed8..0df8a8b317f 100644
--- a/rust/ql/src/queries/summary/Stats.qll
+++ b/rust/ql/src/queries/summary/Stats.qll
@@ -69,7 +69,6 @@ int getTaintEdgesCount() {
}
/**
-<<<<<<< HEAD
* Gets a kind of query for which `n` is a sink (if any).
*/
string getAQuerySinkKind(DataFlow::Node n) {
@@ -81,8 +80,6 @@ string getAQuerySinkKind(DataFlow::Node n) {
}
/**
-=======
->>>>>>> main
* Gets a count of the total number of query sinks in the database.
*/
int getQuerySinksCount() { result = count(QuerySink s) }
From 38f00775bd87f6c1f27608dc23e072671c07cda5 Mon Sep 17 00:00:00 2001
From: Adnan Khan
Date: Fri, 25 Apr 2025 14:49:01 -0400
Subject: [PATCH 027/534] Exclude artifacts downloaded to runner temp.
---
.../ql/lib/codeql/actions/security/ArtifactPoisoningQuery.qll | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/actions/ql/lib/codeql/actions/security/ArtifactPoisoningQuery.qll b/actions/ql/lib/codeql/actions/security/ArtifactPoisoningQuery.qll
index d8d5f83c867..24e0f400e92 100644
--- a/actions/ql/lib/codeql/actions/security/ArtifactPoisoningQuery.qll
+++ b/actions/ql/lib/codeql/actions/security/ArtifactPoisoningQuery.qll
@@ -262,8 +262,9 @@ class ArtifactPoisoningSink extends DataFlow::Node {
ArtifactPoisoningSink() {
download.getAFollowingStep() = poisonable and
- // excluding artifacts downloaded to /tmp
+ // excluding artifacts downloaded to /tmp and runner.tmp
not download.getPath().regexpMatch("^/tmp.*") and
+ not download.getPath().regexpMatch("^\${{\s?runner.temp\s?}}.*") and
(
poisonable.(Run).getScript() = this.asExpr() and
(
From a9c4d6f383c68df3491fb6537519139aacee7681 Mon Sep 17 00:00:00 2001
From: Adnan Khan
Date: Fri, 25 Apr 2025 15:00:14 -0400
Subject: [PATCH 028/534] Fix escaping.
---
.../ql/lib/codeql/actions/security/ArtifactPoisoningQuery.qll | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/actions/ql/lib/codeql/actions/security/ArtifactPoisoningQuery.qll b/actions/ql/lib/codeql/actions/security/ArtifactPoisoningQuery.qll
index 24e0f400e92..8c6471b3c58 100644
--- a/actions/ql/lib/codeql/actions/security/ArtifactPoisoningQuery.qll
+++ b/actions/ql/lib/codeql/actions/security/ArtifactPoisoningQuery.qll
@@ -264,7 +264,7 @@ class ArtifactPoisoningSink extends DataFlow::Node {
download.getAFollowingStep() = poisonable and
// excluding artifacts downloaded to /tmp and runner.tmp
not download.getPath().regexpMatch("^/tmp.*") and
- not download.getPath().regexpMatch("^\${{\s?runner.temp\s?}}.*") and
+ not download.getPath().regexpMatch("^\\${{\\s?runner.temp\\s?}}.*") and
(
poisonable.(Run).getScript() = this.asExpr() and
(
From f96a250ffc511b3d710ef2cb26b896c27aa520f3 Mon Sep 17 00:00:00 2001
From: Lindsay Simpkins
Date: Mon, 9 Jun 2025 18:36:44 -0400
Subject: [PATCH 029/534] fix qhelp files
---
.../src/Metrics/Classes/CNumberOfFunctions.qhelp | 11 +++--------
cpp/ql/src/Metrics/Classes/CSizeOfAPI.qhelp | 12 ++++--------
.../src/Metrics/RefTypes/TInheritanceDepth.qhelp | 14 ++++----------
.../src/Metrics/RefTypes/TNumberOfCallables.qhelp | 12 ++++--------
java/ql/src/Metrics/RefTypes/TNumberOfFields.qhelp | 2 --
java/ql/src/Metrics/RefTypes/TSizeOfAPI.qhelp | 12 ++++--------
6 files changed, 19 insertions(+), 44 deletions(-)
diff --git a/cpp/ql/src/Metrics/Classes/CNumberOfFunctions.qhelp b/cpp/ql/src/Metrics/Classes/CNumberOfFunctions.qhelp
index cc62cb50f49..8ef045c7092 100644
--- a/cpp/ql/src/Metrics/Classes/CNumberOfFunctions.qhelp
+++ b/cpp/ql/src/Metrics/Classes/CNumberOfFunctions.qhelp
@@ -49,21 +49,16 @@ need to be part of the class. (A classic example of this is the
observes, there are at least two key problems with this approach:
-
--
-It may be possible to generalize some of the utility functions beyond the
+1. It may be possible to generalize some of the utility functions beyond the
narrow context of the class in question -- by bundling them with the class,
the class author reduces the scope for functionality reuse.
-
--
-It's usually impossible for the class author to know every possible
+2. It's usually impossible for the class author to know every possible
operation that the user might want to perform on the class, so the public
interface will inherently be incomplete. New utility functions will end up
having a different syntax to the privileged public functions in the class,
negatively impacting on code consistency.
-
-
+
To refactor a class like this, simply move its utility functions elsewhere,
paring its public interface down to the bare minimum.
diff --git a/cpp/ql/src/Metrics/Classes/CSizeOfAPI.qhelp b/cpp/ql/src/Metrics/Classes/CSizeOfAPI.qhelp
index 0d560f920aa..70c4c862fb6 100644
--- a/cpp/ql/src/Metrics/Classes/CSizeOfAPI.qhelp
+++ b/cpp/ql/src/Metrics/Classes/CSizeOfAPI.qhelp
@@ -46,21 +46,17 @@ need to be part of the class. (A classic example of this is the
std::string class in the C++ Standard Library.) As [Sutter]
observes, there are at least two key problems with this approach:
-
--
-It may be possible to generalize some of the utility functions beyond the
+
+1. It may be possible to generalize some of the utility functions beyond the
narrow context of the class in question -- by bundling them with the class,
the class author reduces the scope for functionality reuse.
-
--
-It's usually impossible for the class author to know every possible
+2. It's usually impossible for the class author to know every possible
operation that the user might want to perform on the class, so the public
interface will inherently be incomplete. New utility functions will end up
having a different syntax to the privileged public functions in the class,
negatively impacting on code consistency.
-
-
+
To refactor a class like this, simply move its utility functions elsewhere,
paring its public interface down to the bare minimum.
diff --git a/java/ql/src/Metrics/RefTypes/TInheritanceDepth.qhelp b/java/ql/src/Metrics/RefTypes/TInheritanceDepth.qhelp
index 7d78490985b..970b1c4e19e 100644
--- a/java/ql/src/Metrics/RefTypes/TInheritanceDepth.qhelp
+++ b/java/ql/src/Metrics/RefTypes/TInheritanceDepth.qhelp
@@ -29,14 +29,13 @@ that something is amiss, but further investigation will be needed to clarify
the cause of the problem. Here are two possibilities:
-
-
--
-A class and its superclass represent fundamentally the same abstraction.
+
+1. A class and its superclass represent fundamentally the same abstraction.
In this case, they should generally be merged together (see the 'Collapse
Hierarchy' refactoring on pp.279-80 of [Fowler]). For example, suppose
that in the following class hierarchy both A and C represent fundamentally
the same thing, then they should be merged together as shown:
+
@@ -48,11 +47,9 @@ the same thing, then they should be merged together as shown:
| After |
-
--
-The class hierarchy is trying to represent variation in more than one
+2. The class hierarchy is trying to represent variation in more than one
dimension using single inheritance. This can lead to an unnecessarily
deep class hierarchy with lots of code duplication. For example, consider
the following:
@@ -81,9 +78,6 @@ amount of code duplication that will be necessary.
For readers who are interested in this sort of approach, a good reference is
[West].
-
-
-
diff --git a/java/ql/src/Metrics/RefTypes/TNumberOfCallables.qhelp b/java/ql/src/Metrics/RefTypes/TNumberOfCallables.qhelp
index 49827592849..4f9452789a8 100644
--- a/java/ql/src/Metrics/RefTypes/TNumberOfCallables.qhelp
+++ b/java/ql/src/Metrics/RefTypes/TNumberOfCallables.qhelp
@@ -49,21 +49,17 @@ need to be part of the class. (A classic example of this is the
std::string class in the C++ Standard Library.) As [Sutter]
observes, there are at least two key problems with this approach:
-
--
-It may be possible to generalize some of the utility methods beyond the
+
+1. It may be possible to generalize some of the utility methods beyond the
narrow context of the class in question -- by bundling them with the class,
the class author reduces the scope for functionality reuse.
-
--
-It's usually impossible for the class author to know every possible
+2. It's usually impossible for the class author to know every possible
operation that the user might want to perform on the class, so the public
interface will inherently be incomplete. New utility methods will end up
having a different syntax to the privileged public methods in the class,
negatively impacting on code consistency.
-
-
+
To refactor a class like this, simply move its utility methods elsewhere,
paring its public interface down to the bare minimum.
diff --git a/java/ql/src/Metrics/RefTypes/TNumberOfFields.qhelp b/java/ql/src/Metrics/RefTypes/TNumberOfFields.qhelp
index befc6409449..2934ba958b5 100644
--- a/java/ql/src/Metrics/RefTypes/TNumberOfFields.qhelp
+++ b/java/ql/src/Metrics/RefTypes/TNumberOfFields.qhelp
@@ -25,11 +25,9 @@ If the class is too big, you should split it into multiple smaller classes.
-
If several of the fields are part of the same abstraction, you should
group them into a separate class, using the 'Extract Class' refactoring described
in [Fowler].
-
diff --git a/java/ql/src/Metrics/RefTypes/TSizeOfAPI.qhelp b/java/ql/src/Metrics/RefTypes/TSizeOfAPI.qhelp
index 3095d82049a..eda183a287c 100644
--- a/java/ql/src/Metrics/RefTypes/TSizeOfAPI.qhelp
+++ b/java/ql/src/Metrics/RefTypes/TSizeOfAPI.qhelp
@@ -46,21 +46,17 @@ need to be part of the class. (A classic example of this is the
std::string class in the C++ Standard Library.) As [Sutter]
observes, there are at least two key problems with this approach:
-
--
-It may be possible to generalize some of the utility methods beyond the
+
+1. It may be possible to generalize some of the utility methods beyond the
narrow context of the class in question -- by bundling them with the class,
the class author reduces the scope for functionality reuse.
-
--
-It's usually impossible for the class author to know every possible
+2. It's usually impossible for the class author to know every possible
operation that the user might want to perform on the class, so the public
interface will inherently be incomplete. New utility methods will end up
having a different syntax to the privileged public methods in the class,
negatively impacting on code consistency.
-
-
+
To refactor a class like this, simply move its utility methods elsewhere,
paring its public interface down to the bare minimum.
From 0d803698ac5c6ebde2b664a10ace990362e74c9f Mon Sep 17 00:00:00 2001
From: Paolo Tranquilli
Date: Mon, 16 Jun 2025 14:01:40 +0200
Subject: [PATCH 030/534] Go: remove language tests from workflows
Now that they are run internally using QLucie.
---
.github/workflows/go-tests-other-os.yml | 35 -------------------------
.github/workflows/go-tests-rtjo.yml | 22 ----------------
.github/workflows/go-tests.yml | 13 +--------
go/actions/test/action.yml | 16 -----------
4 files changed, 1 insertion(+), 85 deletions(-)
delete mode 100644 .github/workflows/go-tests-other-os.yml
delete mode 100644 .github/workflows/go-tests-rtjo.yml
diff --git a/.github/workflows/go-tests-other-os.yml b/.github/workflows/go-tests-other-os.yml
deleted file mode 100644
index c06135ab82b..00000000000
--- a/.github/workflows/go-tests-other-os.yml
+++ /dev/null
@@ -1,35 +0,0 @@
-name: "Go: Run Tests - Other OS"
-on:
- pull_request:
- paths:
- - "go/**"
- - "!go/documentation/**"
- - "!go/ql/**" # don't run other-os if only ql/ files changed
- - .github/workflows/go-tests-other-os.yml
- - .github/actions/**
- - codeql-workspace.yml
- - MODULE.bazel
- - .bazelrc
- - misc/bazel/**
-
-permissions:
- contents: read
-
-jobs:
- test-mac:
- name: Test MacOS
- runs-on: macos-latest
- steps:
- - name: Check out code
- uses: actions/checkout@v4
- - name: Run tests
- uses: ./go/actions/test
-
- test-win:
- name: Test Windows
- runs-on: windows-latest
- steps:
- - name: Check out code
- uses: actions/checkout@v4
- - name: Run tests
- uses: ./go/actions/test
diff --git a/.github/workflows/go-tests-rtjo.yml b/.github/workflows/go-tests-rtjo.yml
deleted file mode 100644
index 43721fa1011..00000000000
--- a/.github/workflows/go-tests-rtjo.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-name: "Go: Run RTJO Tests"
-on:
- pull_request:
- types:
- - labeled
-
-permissions:
- contents: read
-
-jobs:
- test-linux:
- if: "github.repository_owner == 'github' && github.event.label.name == 'Run: RTJO Language Tests'"
- name: RTJO Test Linux (Ubuntu)
- runs-on: ubuntu-latest-xl
- steps:
- - name: Check out code
- uses: actions/checkout@v4
- - name: Run tests
- uses: ./go/actions/test
- with:
- run-code-checks: true
- dynamic-join-order-mode: all
diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml
index 994aba44182..c30abdd9e5d 100644
--- a/.github/workflows/go-tests.yml
+++ b/.github/workflows/go-tests.yml
@@ -1,20 +1,9 @@
name: "Go: Run Tests"
on:
- push:
- paths:
- - "go/**"
- - "!go/documentation/**"
- - "shared/**"
- - .github/workflows/go-tests.yml
- - .github/actions/**
- - codeql-workspace.yml
- branches:
- - main
- - "rc/*"
pull_request:
paths:
- "go/**"
- - "!go/documentation/**"
+ - "!go/documentation/**"
- "shared/**"
- .github/workflows/go-tests.yml
- .github/actions/**
diff --git a/go/actions/test/action.yml b/go/actions/test/action.yml
index 667ee4751ba..f777535fec1 100644
--- a/go/actions/test/action.yml
+++ b/go/actions/test/action.yml
@@ -9,10 +9,6 @@ inputs:
description: Whether to run formatting, code and qhelp generation checks
required: false
default: false
- dynamic-join-order-mode:
- description: Value of the --dynamic-join-order-mode flag to pass to the codeql test command
- required: false
- default: "none"
runs:
using: composite
steps:
@@ -67,15 +63,3 @@ runs:
with:
name: qhelp-markdown
path: go/qhelp-out/**/*.md
-
- - name: Cache compilation cache
- id: query-cache
- uses: ./.github/actions/cache-query-compilation
- with:
- key: go-qltest
-
- - name: Test
- shell: bash
- run: |
- cd go
- make test cache="${{ steps.query-cache.outputs.cache-dir }}" rtjo=${{ inputs.dynamic-join-order-mode }}
From cd6975f7b743b19e533bf97de09f54ad06e454ca Mon Sep 17 00:00:00 2001
From: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
Date: Tue, 17 Jun 2025 16:18:47 +0100
Subject: [PATCH 031/534] Rust: Update DotDotCheck from getResolvedPath ->
getCanonicalPath.
---
.../codeql/rust/security/TaintedPathExtensions.qll | 3 ++-
.../security/CWE-022/TaintedPath.expected | 13 +++++++++++++
.../test/query-tests/security/CWE-022/src/main.rs | 4 ++--
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/rust/ql/lib/codeql/rust/security/TaintedPathExtensions.qll b/rust/ql/lib/codeql/rust/security/TaintedPathExtensions.qll
index 5f8d8b77ee8..016d79e840f 100644
--- a/rust/ql/lib/codeql/rust/security/TaintedPathExtensions.qll
+++ b/rust/ql/lib/codeql/rust/security/TaintedPathExtensions.qll
@@ -69,7 +69,8 @@ module SanitizerGuard {
*/
private class DotDotCheck extends SanitizerGuard::Range, CfgNodes::MethodCallExprCfgNode {
DotDotCheck() {
- this.getAstNode().(Resolvable).getResolvedPath() = "::contains" and
+ this.getAstNode().(CallExprBase).getStaticTarget().(Addressable).getCanonicalPath() =
+ "alloc::string::String::contains" and
this.getArgument(0).getAstNode().(LiteralExpr).getTextValue() =
["\"..\"", "\"../\"", "\"..\\\""]
}
diff --git a/rust/ql/test/query-tests/security/CWE-022/TaintedPath.expected b/rust/ql/test/query-tests/security/CWE-022/TaintedPath.expected
index 7d8bb23d4c5..d2d38c18ec0 100644
--- a/rust/ql/test/query-tests/security/CWE-022/TaintedPath.expected
+++ b/rust/ql/test/query-tests/security/CWE-022/TaintedPath.expected
@@ -1,5 +1,6 @@
#select
| src/main.rs:10:5:10:22 | ...::read_to_string | src/main.rs:6:11:6:19 | file_name | src/main.rs:10:5:10:22 | ...::read_to_string | This path depends on a $@. | src/main.rs:6:11:6:19 | file_name | user-provided value |
+| src/main.rs:20:5:20:22 | ...::read_to_string | src/main.rs:14:36:14:44 | file_name | src/main.rs:20:5:20:22 | ...::read_to_string | This path depends on a $@. | src/main.rs:14:36:14:44 | file_name | user-provided value |
| src/main.rs:45:5:45:22 | ...::read_to_string | src/main.rs:37:11:37:19 | file_path | src/main.rs:45:5:45:22 | ...::read_to_string | This path depends on a $@. | src/main.rs:37:11:37:19 | file_path | user-provided value |
| src/main.rs:59:5:59:22 | ...::read_to_string | src/main.rs:50:11:50:19 | file_path | src/main.rs:59:5:59:22 | ...::read_to_string | This path depends on a $@. | src/main.rs:50:11:50:19 | file_path | user-provided value |
edges
@@ -9,6 +10,12 @@ edges
| src/main.rs:8:35:8:43 | file_name | src/main.rs:8:21:8:44 | ...::from(...) | provenance | MaD:4 |
| src/main.rs:8:35:8:43 | file_name | src/main.rs:8:21:8:44 | ...::from(...) | provenance | MaD:4 |
| src/main.rs:10:24:10:32 | file_path | src/main.rs:10:5:10:22 | ...::read_to_string | provenance | MaD:1 Sink:MaD:1 |
+| src/main.rs:14:36:14:44 | file_name | src/main.rs:19:35:19:43 | file_name | provenance | |
+| src/main.rs:19:9:19:17 | file_path | src/main.rs:20:24:20:32 | file_path | provenance | |
+| src/main.rs:19:21:19:44 | ...::from(...) | src/main.rs:19:9:19:17 | file_path | provenance | |
+| src/main.rs:19:35:19:43 | file_name | src/main.rs:19:21:19:44 | ...::from(...) | provenance | MaD:4 |
+| src/main.rs:19:35:19:43 | file_name | src/main.rs:19:21:19:44 | ...::from(...) | provenance | MaD:4 |
+| src/main.rs:20:24:20:32 | file_path | src/main.rs:20:5:20:22 | ...::read_to_string | provenance | MaD:1 Sink:MaD:1 |
| src/main.rs:37:11:37:19 | file_path | src/main.rs:40:52:40:60 | file_path | provenance | |
| src/main.rs:40:9:40:17 | file_path | src/main.rs:45:24:45:32 | file_path | provenance | |
| src/main.rs:40:21:40:62 | public_path.join(...) | src/main.rs:40:9:40:17 | file_path | provenance | |
@@ -38,6 +45,12 @@ nodes
| src/main.rs:8:35:8:43 | file_name | semmle.label | file_name |
| src/main.rs:10:5:10:22 | ...::read_to_string | semmle.label | ...::read_to_string |
| src/main.rs:10:24:10:32 | file_path | semmle.label | file_path |
+| src/main.rs:14:36:14:44 | file_name | semmle.label | file_name |
+| src/main.rs:19:9:19:17 | file_path | semmle.label | file_path |
+| src/main.rs:19:21:19:44 | ...::from(...) | semmle.label | ...::from(...) |
+| src/main.rs:19:35:19:43 | file_name | semmle.label | file_name |
+| src/main.rs:20:5:20:22 | ...::read_to_string | semmle.label | ...::read_to_string |
+| src/main.rs:20:24:20:32 | file_path | semmle.label | file_path |
| src/main.rs:37:11:37:19 | file_path | semmle.label | file_path |
| src/main.rs:40:9:40:17 | file_path | semmle.label | file_path |
| src/main.rs:40:21:40:62 | public_path.join(...) | semmle.label | public_path.join(...) |
diff --git a/rust/ql/test/query-tests/security/CWE-022/src/main.rs b/rust/ql/test/query-tests/security/CWE-022/src/main.rs
index 7c13da08db5..7882060230d 100644
--- a/rust/ql/test/query-tests/security/CWE-022/src/main.rs
+++ b/rust/ql/test/query-tests/security/CWE-022/src/main.rs
@@ -11,13 +11,13 @@ fn tainted_path_handler_bad(
}
//#[handler]
-fn tainted_path_handler_good(Query(file_name): Query) -> Result {
+fn tainted_path_handler_good(Query(file_name): Query) -> Result { // $ SPURIOUS: Source=remote2
// GOOD: ensure that the filename has no path separators or parent directory references
if file_name.contains("..") || file_name.contains("/") || file_name.contains("\\") {
return Err(Error::from_status(StatusCode::BAD_REQUEST));
}
let file_path = PathBuf::from(file_name);
- fs::read_to_string(file_path).map_err(InternalServerError) // $ path-injection-sink
+ fs::read_to_string(file_path).map_err(InternalServerError) // $ path-injection-sink SPURIOUS: Alert[rust/path-injection]=remote2
}
//#[handler]
From de9dab9ba31e74125bb6fb53f68314975188c2ff Mon Sep 17 00:00:00 2001
From: Asger F
Date: Wed, 4 Jun 2025 12:26:00 +0200
Subject: [PATCH 032/534] JS: Move some predicates into NameResolution
---
.../ql/lib/semmle/javascript/internal/NameResolution.qll | 4 ++++
.../ql/lib/semmle/javascript/internal/TypeResolution.qll | 4 ----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/javascript/ql/lib/semmle/javascript/internal/NameResolution.qll b/javascript/ql/lib/semmle/javascript/internal/NameResolution.qll
index 96e72108e2e..cbcca9fe810 100644
--- a/javascript/ql/lib/semmle/javascript/internal/NameResolution.qll
+++ b/javascript/ql/lib/semmle/javascript/internal/NameResolution.qll
@@ -408,6 +408,10 @@ module NameResolution {
*/
predicate trackModule = ValueFlow::TrackNode::track/1;
+ predicate trackClassValue = ValueFlow::TrackNode::track/1;
+
+ predicate trackFunctionValue = ValueFlow::TrackNode::track/1;
+
/**
* Holds if `moduleName` appears to start with a package name, as opposed to a relative file import.
*/
diff --git a/javascript/ql/lib/semmle/javascript/internal/TypeResolution.qll b/javascript/ql/lib/semmle/javascript/internal/TypeResolution.qll
index ddf5757a38c..9829651621e 100644
--- a/javascript/ql/lib/semmle/javascript/internal/TypeResolution.qll
+++ b/javascript/ql/lib/semmle/javascript/internal/TypeResolution.qll
@@ -4,8 +4,6 @@ private import semmle.javascript.internal.UnderlyingTypes
private import semmle.javascript.dataflow.internal.sharedlib.SummaryTypeTracker as SummaryTypeTracker
module TypeResolution {
- predicate trackClassValue = ValueFlow::TrackNode::track/1;
-
predicate trackType = TypeFlow::TrackNode::track/1;
/**
@@ -24,8 +22,6 @@ module TypeResolution {
)
}
- predicate trackFunctionValue = ValueFlow::TrackNode::track/1;
-
/**
* Gets the representative for the type containing the given member.
*
From 2a0c7c8801b0b03a5e1cf447fc44aa9ccba79abc Mon Sep 17 00:00:00 2001
From: Asger F
Date: Wed, 4 Jun 2025 12:26:28 +0200
Subject: [PATCH 033/534] JS: Add classHasGlobalName into NameResolution
---
.../ql/lib/semmle/javascript/internal/NameResolution.qll | 6 ++++++
.../ql/lib/semmle/javascript/internal/UnderlyingTypes.qll | 6 ------
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/javascript/ql/lib/semmle/javascript/internal/NameResolution.qll b/javascript/ql/lib/semmle/javascript/internal/NameResolution.qll
index cbcca9fe810..5725181baa0 100644
--- a/javascript/ql/lib/semmle/javascript/internal/NameResolution.qll
+++ b/javascript/ql/lib/semmle/javascript/internal/NameResolution.qll
@@ -513,4 +513,10 @@ module NameResolution {
qualifiedName = append(prefix, step)
)
}
+
+ pragma[nomagic]
+ predicate classHasGlobalName(DataFlow::ClassNode cls, string name) {
+ cls.flowsTo(AccessPath::getAnAssignmentTo(name)) and
+ not cls.getTopLevel().isExterns() // don't propagate externs classes
+ }
}
diff --git a/javascript/ql/lib/semmle/javascript/internal/UnderlyingTypes.qll b/javascript/ql/lib/semmle/javascript/internal/UnderlyingTypes.qll
index 8f6628278c4..5461cb3d50f 100644
--- a/javascript/ql/lib/semmle/javascript/internal/UnderlyingTypes.qll
+++ b/javascript/ql/lib/semmle/javascript/internal/UnderlyingTypes.qll
@@ -119,10 +119,4 @@ module UnderlyingTypes {
// The caller is responsible for handling the class hierarchy.
)
}
-
- pragma[nomagic]
- private predicate classHasGlobalName(DataFlow::ClassNode cls, string name) {
- cls.flowsTo(AccessPath::getAnAssignmentTo(name)) and
- not cls.getTopLevel().isExterns() // don't propagate externs classes
- }
}
From b82e84930c0b200efbbdcb55efda9a20dfdb2246 Mon Sep 17 00:00:00 2001
From: Asger F
Date: Wed, 4 Jun 2025 12:27:07 +0200
Subject: [PATCH 034/534] JS: Add public API
---
javascript/ql/lib/semmle/javascript/AST.qll | 19 +++
.../lib/semmle/javascript/TypeAnnotations.qll | 9 +
.../javascript/internal/BindingInfo.qll | 159 ++++++++++++++++++
.../javascript/internal/NameResolution.qll | 15 ++
4 files changed, 202 insertions(+)
create mode 100644 javascript/ql/lib/semmle/javascript/internal/BindingInfo.qll
diff --git a/javascript/ql/lib/semmle/javascript/AST.qll b/javascript/ql/lib/semmle/javascript/AST.qll
index 90b8494d166..bcde7bbaf4a 100644
--- a/javascript/ql/lib/semmle/javascript/AST.qll
+++ b/javascript/ql/lib/semmle/javascript/AST.qll
@@ -5,6 +5,8 @@
import javascript
private import internal.StmtContainers
private import semmle.javascript.internal.CachedStages
+private import semmle.javascript.internal.TypeResolution
+private import semmle.javascript.internal.BindingInfo
/**
* A program element corresponding to JavaScript code, such as an expression
@@ -472,5 +474,22 @@ module AST {
/** Gets the data flow node associated with this program element. */
DataFlow::ValueNode flow() { result = DataFlow::valueNode(this) }
+
+ /**
+ * Gets information about the results of name-resolution for this expression.
+ *
+ * This can be used to map an expression to the class it refers to, or
+ * associate it with a named value coming from an dependency.
+ */
+ ExprNameBindingNode getNameBinding() { result = this }
+
+ /**
+ * Gets information about the type of this expression.
+ *
+ * This can be used to map an expression to the classes it may be an instance of
+ * (according to the type system), or to associate it with a named type coming
+ * from a dependency.
+ */
+ TypeNameBindingNode getTypeBinding() { TypeResolution::valueHasType(this, result) }
}
}
diff --git a/javascript/ql/lib/semmle/javascript/TypeAnnotations.qll b/javascript/ql/lib/semmle/javascript/TypeAnnotations.qll
index 318ad2f8873..d9944b311ea 100644
--- a/javascript/ql/lib/semmle/javascript/TypeAnnotations.qll
+++ b/javascript/ql/lib/semmle/javascript/TypeAnnotations.qll
@@ -6,11 +6,20 @@ import javascript
private import internal.StmtContainers
private import internal.NameResolution
private import internal.UnderlyingTypes
+private import internal.BindingInfo
/**
* A type annotation, either in the form of a TypeScript type or a JSDoc comment.
*/
class TypeAnnotation extends @type_annotation, NodeInStmtContainer {
+ /**
+ * Gets information about the results of name-resolution for this type.
+ *
+ * This can be used to map a type name to the class/interface it refers to, or
+ * associate it with a named type coming from an dependency.
+ */
+ TypeNameBindingNode getTypeBinding() { result = this }
+
/** Holds if this is the `any` type. */
predicate isAny() { none() }
diff --git a/javascript/ql/lib/semmle/javascript/internal/BindingInfo.qll b/javascript/ql/lib/semmle/javascript/internal/BindingInfo.qll
new file mode 100644
index 00000000000..e5d3c3e4819
--- /dev/null
+++ b/javascript/ql/lib/semmle/javascript/internal/BindingInfo.qll
@@ -0,0 +1,159 @@
+/**
+ * Provides a limited public interface to name/type resolution information.
+ */
+
+private import javascript
+private import semmle.javascript.internal.NameResolution
+private import semmle.javascript.internal.TypeResolution
+private import semmle.javascript.internal.UnderlyingTypes
+
+/**
+ * Interface for accessing name-resolution info about type names.
+ */
+class TypeNameBindingNode extends NameResolution::Node {
+ /**
+ * Holds if type refers to, or is an alias for, the given type name relative to the global scope.
+ *
+ * For example:
+ * ```ts
+ * var x: Document; // hasQualifiedName("Document")
+ * var x: Electron; // hasQualifiedName("Electron")
+ * var x: Electron.BrowserWindow; // hasQualifiedName("Electron.BrowserWindow")
+ * ```
+ */
+ predicate hasQualifiedName(string qualifiedName) {
+ NameResolution::nodeRefersToModule(this, "global", qualifiedName)
+ }
+
+ /**
+ * Holds if this refers a value exported by the given module, with the given
+ * qualified name. If the `qualifiedName` is empty, this refers to the module itself.
+ *
+ * For example, the type annotations below have the following name bindings:
+ * ```ts
+ * import { Request } from "express";
+ *
+ * var x: Request; // hasUnderlyingType("express", "Request")
+ * var x: Request | null; // no result (see hasUnderlyingType)
+ * var x: Request & { prop: string }; // no result (see hasUnderlyingType)
+ *
+ * interface CustomSubtype extends Request {}
+ *
+ * var x: CustomSubtype; // no result (see hasUnderlyingType)
+ *
+ * var x: typeof import("express"); // hasUnderlyingType("express", "")
+ * ```
+ */
+ predicate hasQualifiedName(string moduleName, string qualifiedName) {
+ NameResolution::nodeRefersToModule(this, moduleName, qualifiedName)
+ }
+
+ /**
+ * Holds if this type refers to the given type exported from the given module, after
+ * unfolding unions and intersections, and following subtype relations.
+ *
+ * For example:
+ * ```ts
+ * import { Request } from "express";
+ *
+ * var x: Request; // hasUnderlyingType("express", "Request")
+ * var x: Request | null; // hasUnderlyingType("express", "Request")
+ * var x: Request & { prop: string }; // hasUnderlyingType("express", "Request")
+ *
+ * interface CustomSubtype extends Request {}
+ *
+ * var x: CustomSubtype; // hasUnderlyingType("express", "Request")
+ * ```
+ */
+ predicate hasUnderlyingType(string moduleName, string qualifiedName) {
+ UnderlyingTypes::nodeHasUnderlyingType(this, moduleName, qualifiedName)
+ }
+
+ /**
+ * Holds if this type refers to the given type from the global scope, after
+ * unfolding unions and intersections, and following subtype relations.
+ *
+ * For example:
+ * ```ts
+ * var x: Document; // hasUnderlyingType("Document")
+ * var x: Document | null; // hasUnderlyingType("Document")
+ * var x: Document & { prop: string }; // hasUnderlyingType("Document")
+ *
+ * interface CustomSubtype extends Document {}
+ *
+ * var x: CustomSubtype; // hasUnderlyingType("Document")
+ * ```
+ */
+ predicate hasUnderlyingType(string qualifiedName) {
+ UnderlyingTypes::nodeHasUnderlyingType(this, qualifiedName)
+ }
+
+ /**
+ * Gets the declaration of the type being referenced by this name.
+ *
+ * For example:
+ * ```ts
+ * class Foo {}
+ *
+ * type T = Foo;
+ * var x: T; // getTypeDefinition() maps T to the class Foo above
+ * ```
+ *
+ * Note that this has no result for function-style classes referenced from
+ * a JSDoc comment.
+ */
+ TypeDefinition getTypeDefinition() { TypeResolution::trackType(result) = this }
+
+ /**
+ * Gets a class that this type refers to, after unfolding unions and intersections (but not subtyping).
+ *
+ * For example, the type of `x` maps to the class `C` in each example below:
+ * ```ts
+ * class C {}
+ *
+ * var x: C;
+ * var x: C | null;
+ * var x: C & { prop: string };
+ * ```
+ */
+ DataFlow::ClassNode getAnUnderlyingClass() {
+ UnderlyingTypes::nodeHasUnderlyingClassType(this, result)
+ }
+}
+
+/**
+ * Interface for accessing name-resolution info about expressions.
+ */
+class ExprNameBindingNode extends NameResolution::Node {
+ /**
+ * Holds if this refers a value exported by the given module, with the given
+ * qualified name. If the `qualifiedName` is empty, this refers to the module itself.
+ *
+ * For example, the type annotations below have the following name bindings:
+ * ```ts
+ * import * as f from "foo";
+ *
+ * var x = f; // hasQualifiedName(f, "")
+ * var x = f.x.y; // hasQualifiedName(f, "x.y")
+ * ```
+ */
+ predicate hasQualifiedName(string moduleName, string qualifiedName) {
+ NameResolution::nodeRefersToModule(this, moduleName, qualifiedName)
+ }
+
+ /**
+ * Gets the class, or function acting as a class, referenced by this name.
+ *
+ * ```ts
+ * class Foo {}
+ * const T = Foo;
+ * var x = T; // getClassNode() maps T to the class Foo above
+ *
+ * function Bar() {}
+ * Bar.prototype.blah = function() {};
+ * const S = Bar;
+ * var x = S; // getClassNode() maps S to the function Bar above
+ * ```
+ */
+ DataFlow::ClassNode getClassNode() { NameResolution::nodeRefersToClass(this, result) }
+}
diff --git a/javascript/ql/lib/semmle/javascript/internal/NameResolution.qll b/javascript/ql/lib/semmle/javascript/internal/NameResolution.qll
index 5725181baa0..7496b6c0482 100644
--- a/javascript/ql/lib/semmle/javascript/internal/NameResolution.qll
+++ b/javascript/ql/lib/semmle/javascript/internal/NameResolution.qll
@@ -519,4 +519,19 @@ module NameResolution {
cls.flowsTo(AccessPath::getAnAssignmentTo(name)) and
not cls.getTopLevel().isExterns() // don't propagate externs classes
}
+
+ /**
+ * Holds if `node` refers to the given class.
+ */
+ pragma[nomagic]
+ predicate nodeRefersToClass(Node node, DataFlow::ClassNode cls) {
+ exists(string name |
+ classHasGlobalName(cls, name) and
+ nodeRefersToModule(node, "global", name)
+ )
+ or
+ trackClassValue(cls.getAstNode()) = node
+ or
+ trackFunctionValue(cls.getAstNode()) = node
+ }
}
From 17a687b38f5021e30bd2f7af0b0d21bec2ed4697 Mon Sep 17 00:00:00 2001
From: Asger F
Date: Mon, 2 Jun 2025 14:26:01 +0200
Subject: [PATCH 035/534] JS: Update type usage in Nest library model
---
.../ql/lib/semmle/javascript/frameworks/Nest.qll | 15 +++++++--------
.../semmle/javascript/internal/BindingInfo.qll | 13 +++++++++++++
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/javascript/ql/lib/semmle/javascript/frameworks/Nest.qll b/javascript/ql/lib/semmle/javascript/frameworks/Nest.qll
index d6bcb9ddd40..34fca2d57c9 100644
--- a/javascript/ql/lib/semmle/javascript/frameworks/Nest.qll
+++ b/javascript/ql/lib/semmle/javascript/frameworks/Nest.qll
@@ -5,8 +5,6 @@
import javascript
private import semmle.javascript.security.dataflow.ServerSideUrlRedirectCustomizations
private import semmle.javascript.dataflow.internal.PreCallGraphStep
-private import semmle.javascript.internal.NameResolution
-private import semmle.javascript.internal.TypeResolution
/**
* Provides classes and predicates for reasoning about [Nest](https://nestjs.com/).
@@ -137,7 +135,7 @@ module NestJS {
hasSanitizingPipe(this, true) and
// Note: we could consider types with class-validator decorators to be sanitized here, but instead we consider the root
// object to be tainted, but omit taint steps for the individual properties names that have sanitizing decorators. See ClassValidator.qll.
- TypeResolution::isSanitizingPrimitiveType(this.getParameter().getTypeAnnotation())
+ this.getParameter().getTypeBinding().isSanitizingPrimitiveType()
}
}
@@ -337,9 +335,10 @@ module NestJS {
handler.isReturnValueReflected() and
this = handler.getAReturn() and
// Only returned strings are sinks. If we can find a type for the return value, it must be string-like.
- not exists(NameResolution::Node type |
- TypeResolution::valueHasType(this.asExpr(), type) and
- not TypeResolution::hasUnderlyingStringOrAnyType(type)
+ (
+ this.asExpr().getTypeBinding().hasUnderlyingStringOrAnyType()
+ or
+ not exists(this.asExpr().getTypeBinding())
)
}
@@ -475,7 +474,7 @@ module NestJS {
/** Gets the class being referenced at `node` without relying on the call graph. */
private DataFlow::ClassNode getClassFromNode(DataFlow::Node node) {
- result.getAstNode() = node.analyze().getAValue().(AbstractClass).getClass()
+ result = node.asExpr().getNameBinding().getClassNode()
}
private predicate providerClassPair(
@@ -491,7 +490,7 @@ module NestJS {
private class DependencyInjectionStep extends PreCallGraphStep {
override predicate classInstanceSource(DataFlow::ClassNode cls, DataFlow::Node node) {
exists(DataFlow::ClassNode interfaceClass |
- node.asExpr().(Parameter).getType().(ClassType).getClass() = interfaceClass.getAstNode() and
+ node.asExpr().getTypeBinding().getTypeDefinition() = interfaceClass.getAstNode() and
providerClassPair(interfaceClass, cls)
)
}
diff --git a/javascript/ql/lib/semmle/javascript/internal/BindingInfo.qll b/javascript/ql/lib/semmle/javascript/internal/BindingInfo.qll
index e5d3c3e4819..bc3db9ef3a9 100644
--- a/javascript/ql/lib/semmle/javascript/internal/BindingInfo.qll
+++ b/javascript/ql/lib/semmle/javascript/internal/BindingInfo.qll
@@ -119,6 +119,19 @@ class TypeNameBindingNode extends NameResolution::Node {
DataFlow::ClassNode getAnUnderlyingClass() {
UnderlyingTypes::nodeHasUnderlyingClassType(this, result)
}
+
+ /**
+ * Holds if this type contains `string` or `any`, possibly wrapped in a promise.
+ */
+ predicate hasUnderlyingStringOrAnyType() { TypeResolution::hasUnderlyingStringOrAnyType(this) }
+
+ /**
+ * Holds if this refers to a type that is considered untaintable (if actually enforced at runtime).
+ *
+ * Specifically, the types `number`, `boolean`, `null`, `undefined`, `void`, `never`, as well as literal types (`"foo"`)
+ * and enums and enum members have this property.
+ */
+ predicate isSanitizingPrimitiveType() { TypeResolution::isSanitizingPrimitiveType(this) }
}
/**
From 9d4c38b5f1d17bd915460f95044bde8901f854fb Mon Sep 17 00:00:00 2001
From: Asger F
Date: Tue, 3 Jun 2025 13:50:27 +0200
Subject: [PATCH 036/534] JS: Update type usage in definitions.qll
---
javascript/ql/lib/definitions.qll | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/javascript/ql/lib/definitions.qll b/javascript/ql/lib/definitions.qll
index 2f1c99b7c60..54ad0c3548a 100644
--- a/javascript/ql/lib/definitions.qll
+++ b/javascript/ql/lib/definitions.qll
@@ -126,7 +126,7 @@ private predicate propertyLookup(Expr prop, AstNode write, string kind) {
private predicate typeLookup(AstNode ref, AstNode decl, string kind) {
exists(TypeAccess typeAccess |
ref = typeAccess.getIdentifier() and
- decl = typeAccess.getTypeName().getADefinition() and
+ decl = typeAccess.getTypeBinding().getTypeDefinition() and
kind = "T"
)
}
From ace8b09a3602cddf78d01c67179836f7a4918bad Mon Sep 17 00:00:00 2001
From: Asger F
Date: Wed, 11 Jun 2025 10:45:44 +0200
Subject: [PATCH 037/534] JS: Update type usage in ClassValidator.qll
---
.../ql/lib/semmle/javascript/frameworks/ClassValidator.qll | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/javascript/ql/lib/semmle/javascript/frameworks/ClassValidator.qll b/javascript/ql/lib/semmle/javascript/frameworks/ClassValidator.qll
index 35f966217bd..8b2ef364054 100644
--- a/javascript/ql/lib/semmle/javascript/frameworks/ClassValidator.qll
+++ b/javascript/ql/lib/semmle/javascript/frameworks/ClassValidator.qll
@@ -50,7 +50,7 @@ module ClassValidator {
pragma[noinline]
private ClassDefinition getClassReferencedByPropRead(DataFlow::PropRead read) {
- read.getBase().asExpr().getType().unfold().(ClassType).getClass() = result
+ read.getBase().asExpr().getTypeBinding().getAnUnderlyingClass().getAstNode() = result
}
/**
From b71d09630a67c0d40f4f73560432781657c5fa16 Mon Sep 17 00:00:00 2001
From: Asger F
Date: Mon, 2 Jun 2025 14:33:02 +0200
Subject: [PATCH 038/534] JS: Update type usage in Electron model
---
.../semmle/javascript/frameworks/Electron.qll | 19 ++++++++++---------
.../frameworks/Electron/tests.expected | 2 ++
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/javascript/ql/lib/semmle/javascript/frameworks/Electron.qll b/javascript/ql/lib/semmle/javascript/frameworks/Electron.qll
index 48b1875a445..796770b96ee 100644
--- a/javascript/ql/lib/semmle/javascript/frameworks/Electron.qll
+++ b/javascript/ql/lib/semmle/javascript/frameworks/Electron.qll
@@ -41,18 +41,19 @@ module Electron {
BrowserView() { this = DataFlow::moduleMember("electron", "BrowserView").getAnInstantiation() }
}
- /**
- * An expression of type `BrowserWindow` or `BrowserView`.
- */
- private class BrowserObjectByType extends BrowserObject {
- BrowserObjectByType() {
- exists(string tp | tp = "BrowserWindow" or tp = "BrowserView" |
- this.asExpr().getType().hasUnderlyingType("electron", tp)
- )
+ private class ElectronEntryPoint extends API::EntryPoint {
+ ElectronEntryPoint() { this = "Electron.Browser" }
+
+ override DataFlow::SourceNode getASource() {
+ result.hasUnderlyingType(["Electron.BrowserWindow", "Electron.BrowserView"])
}
}
- private API::Node browserObject() { result.asSource() instanceof NewBrowserObject }
+ private API::Node browserObject() {
+ result.asSource() instanceof NewBrowserObject or
+ result = API::Node::ofType("electron", ["BrowserWindow", "BrowserView"]) or
+ result = any(ElectronEntryPoint e).getANode()
+ }
/**
* A data flow node whose value may originate from a browser object instantiation.
diff --git a/javascript/ql/test/library-tests/frameworks/Electron/tests.expected b/javascript/ql/test/library-tests/frameworks/Electron/tests.expected
index 3050fb8fa53..72fb0a737b8 100644
--- a/javascript/ql/test/library-tests/frameworks/Electron/tests.expected
+++ b/javascript/ql/test/library-tests/frameworks/Electron/tests.expected
@@ -16,6 +16,8 @@ browserObject
| electron.js:63:3:63:5 | win |
| electron.js:65:18:65:20 | win |
| electronTs.ts:3:12:3:13 | bw |
+| electronTs.ts:3:12:3:13 | bw |
+| electronTs.ts:3:40:3:41 | bv |
| electronTs.ts:3:40:3:41 | bv |
| electronTs.ts:4:3:4:4 | bw |
| electronTs.ts:5:3:5:4 | bv |
From 8b2a424fb004e96bddd8fb419b35ba3c81afc0db Mon Sep 17 00:00:00 2001
From: Asger F
Date: Mon, 2 Jun 2025 14:33:13 +0200
Subject: [PATCH 039/534] JS: Update type usage use in Express model
---
javascript/ql/lib/semmle/javascript/frameworks/Express.qll | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/javascript/ql/lib/semmle/javascript/frameworks/Express.qll b/javascript/ql/lib/semmle/javascript/frameworks/Express.qll
index bcfcffb82a0..8c016b3afe9 100644
--- a/javascript/ql/lib/semmle/javascript/frameworks/Express.qll
+++ b/javascript/ql/lib/semmle/javascript/frameworks/Express.qll
@@ -48,7 +48,7 @@ module Express {
private predicate isRouter(DataFlow::Node e) {
isRouter(e, _)
or
- e.asExpr().getType().hasUnderlyingType("express", "Router")
+ e.(DataFlow::SourceNode).hasUnderlyingType("express", "Router")
or
// created by `webpack-dev-server`
WebpackDevServer::webpackDevServerApp().flowsTo(e)
From fb92d9b034a783e7a15533f057affda2bd9983ae Mon Sep 17 00:00:00 2001
From: Asger F
Date: Mon, 2 Jun 2025 16:07:47 +0200
Subject: [PATCH 040/534] JS: Update type usage in UnreachableMethodOverloads
This query depended on the cons-hashing performed by type extraction to determine if two types are the same.
This is not trivial to restore, but not important enough to reimplement right now, so for now just simplifying the query's ability to recognise that two types are the same.
---
.../UnreachableMethodOverloads.ql | 40 ++++++++++++-------
.../UnreachableMethodOverloads.expected | 3 --
.../Declarations/UnreachableOverloads/tst.ts | 6 +--
3 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/javascript/ql/src/Declarations/UnreachableMethodOverloads.ql b/javascript/ql/src/Declarations/UnreachableMethodOverloads.ql
index a68617ea2f1..912d58ab54c 100644
--- a/javascript/ql/src/Declarations/UnreachableMethodOverloads.ql
+++ b/javascript/ql/src/Declarations/UnreachableMethodOverloads.ql
@@ -45,20 +45,22 @@ string getKind(MemberDeclaration m) {
/**
* A call-signature that originates from a MethodSignature in the AST.
*/
-private class MethodCallSig extends CallSignatureType {
- string name;
+private class MethodCallSig extends Function {
+ private MethodSignature signature;
- MethodCallSig() {
- exists(MethodSignature sig |
- this = sig.getBody().getCallSignature() and
- name = sig.getName()
- )
+ MethodCallSig() { this = signature.getBody() }
+
+ int getNumOptionalParameter() {
+ result = count(Parameter p | p = this.getParameter(_) and p.isDeclaredOptional())
}
- /**
- * Gets the name of any member that has this signature.
- */
- string getName() { result = name }
+ int getNumRequiredParameter() {
+ result = count(Parameter p | p = this.getParameter(_) and not p.isDeclaredOptional())
+ }
+
+ SignatureKind getKind() { result = SignatureKind::function() }
+
+ TypeExpr getTypeParameterBound(int i) { result = this.getTypeParameter(i).getBound() }
}
pragma[noinline]
@@ -75,6 +77,7 @@ private MethodCallSig getMethodCallSigWithFingerprint(
/**
* Holds if the two call signatures could be overloads of each other and have the same parameter types.
*/
+pragma[inline]
predicate matchingCallSignature(MethodCallSig method, MethodCallSig other) {
other =
getMethodCallSigWithFingerprint(method.getName(), method.getNumOptionalParameter(),
@@ -109,6 +112,16 @@ private MethodSignature getMethodSignatureWithFingerprint(
result.getBody().getNumParameter() = numParameters
}
+bindingset[t1, t2]
+pragma[inline_late]
+private predicate sameType(TypeExpr t1, TypeExpr t2) {
+ t1.(PredefinedTypeExpr).getName() = t2.(PredefinedTypeExpr).getName()
+ or
+ t1 instanceof ThisTypeExpr and t2 instanceof ThisTypeExpr
+ or
+ t1.(LocalTypeAccess).getLocalTypeName() = t2.(LocalTypeAccess).getLocalTypeName()
+}
+
/**
* Holds if the two method signatures are overloads of each other and have the same parameter types.
*/
@@ -122,14 +135,13 @@ predicate signaturesMatch(MethodSignature method, MethodSignature other) {
not exists(method.getBody().getThisTypeAnnotation()) and
not exists(other.getBody().getThisTypeAnnotation())
or
- method.getBody().getThisTypeAnnotation().getType() =
- other.getBody().getThisTypeAnnotation().getType()
+ sameType(method.getBody().getThisTypeAnnotation(), other.getBody().getThisTypeAnnotation())
) and
// The types are compared in matchingCallSignature. This is a consistency check that the textual representation of the type-annotations are somewhat similar.
forall(int i | i in [0 .. -1 + method.getBody().getNumParameter()] |
getParameterTypeAnnotation(method, i) = getParameterTypeAnnotation(other, i)
) and
- matchingCallSignature(method.getBody().getCallSignature(), other.getBody().getCallSignature())
+ matchingCallSignature(method.getBody(), other.getBody())
}
from ClassOrInterface decl, string name, MethodSignature previous, MethodSignature unreachable
diff --git a/javascript/ql/test/query-tests/Declarations/UnreachableOverloads/UnreachableMethodOverloads.expected b/javascript/ql/test/query-tests/Declarations/UnreachableOverloads/UnreachableMethodOverloads.expected
index 44bd568e767..24767950a66 100644
--- a/javascript/ql/test/query-tests/Declarations/UnreachableOverloads/UnreachableMethodOverloads.expected
+++ b/javascript/ql/test/query-tests/Declarations/UnreachableOverloads/UnreachableMethodOverloads.expected
@@ -1,5 +1,2 @@
-| tst.ts:3:3:3:30 | method( ... number; | This overload of method() is unreachable, the $@ overload will always be selected. | tst.ts:2:3:2:30 | method( ... string; | previous |
| tst.ts:6:3:6:17 | types1(): any[] | This overload of types1() is unreachable, the $@ overload will always be selected. | tst.ts:5:3:5:18 | types1(): T[] | previous |
-| tst.ts:15:3:15:74 | on(even ... nction; | This overload of on() is unreachable, the $@ overload will always be selected. | tst.ts:14:3:14:74 | on(even ... nction; | previous |
| tst.ts:21:3:21:28 | bar(thi ... number; | This overload of bar() is unreachable, the $@ overload will always be selected. | tst.ts:20:3:20:28 | bar(thi ... string; | previous |
-| tst.ts:27:3:27:30 | method( ... number; | This overload of method() is unreachable, the $@ overload will always be selected. | tst.ts:26:3:26:30 | method( ... string; | previous |
diff --git a/javascript/ql/test/query-tests/Declarations/UnreachableOverloads/tst.ts b/javascript/ql/test/query-tests/Declarations/UnreachableOverloads/tst.ts
index 17d95f835cf..4ffd64bc7c1 100644
--- a/javascript/ql/test/query-tests/Declarations/UnreachableOverloads/tst.ts
+++ b/javascript/ql/test/query-tests/Declarations/UnreachableOverloads/tst.ts
@@ -1,6 +1,6 @@
declare class Foobar {
method(foo: number): string;
- method(foo: number): number; // $ Alert
+ method(foo: number): number; // $ MISSING: Alert
types1(): T[]
types1(): any[] // $ Alert
@@ -12,7 +12,7 @@ declare class Foobar {
types3(t: T): number
on(event: string, fn?: (event?: any, ...args: any[]) => void): Function;
- on(event: string, fn?: (event?: any, ...args: any[]) => void): Function; // $ Alert
+ on(event: string, fn?: (event?: any, ...args: any[]) => void): Function; // $ MISSING: Alert
foo(this: string): string;
foo(this: number): number;
@@ -24,7 +24,7 @@ declare class Foobar {
declare class Base {
method(foo: number): string;
- method(foo: number): number; // $ Alert
+ method(foo: number): number; // $ MISSING: Alert
overRiddenInSub(): string;
overRiddenInSub(): number;
From e459884b696b125d9dd1de2924288f0b3ac9b9c4 Mon Sep 17 00:00:00 2001
From: Asger F
Date: Wed, 4 Jun 2025 12:46:43 +0200
Subject: [PATCH 041/534] JS: Update API usage in ViewComponentInput
---
javascript/ql/lib/semmle/javascript/ViewComponentInput.qll | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/javascript/ql/lib/semmle/javascript/ViewComponentInput.qll b/javascript/ql/lib/semmle/javascript/ViewComponentInput.qll
index 7ab04ad5bd2..43cd337685d 100644
--- a/javascript/ql/lib/semmle/javascript/ViewComponentInput.qll
+++ b/javascript/ql/lib/semmle/javascript/ViewComponentInput.qll
@@ -3,7 +3,6 @@
*/
private import javascript
-private import semmle.javascript.internal.TypeResolution
/**
* An input to a view component, such as React props.
@@ -16,7 +15,7 @@ abstract class ViewComponentInput extends DataFlow::Node {
private class ViewComponentInputAsThreatModelSource extends ThreatModelSource::Range instanceof ViewComponentInput
{
ViewComponentInputAsThreatModelSource() {
- not TypeResolution::valueHasSanitizingPrimitiveType(this.asExpr())
+ not this.asExpr().getTypeBinding().isSanitizingPrimitiveType()
}
final override string getThreatModel() { result = "view-component-input" }
From fcb6882f169fab17f54db329cc556587d41cf8cb Mon Sep 17 00:00:00 2001
From: Asger F
Date: Wed, 4 Jun 2025 12:48:39 +0200
Subject: [PATCH 042/534] JS: Update API usage in MissingAwait
---
javascript/ql/lib/semmle/javascript/internal/BindingInfo.qll | 5 +++++
javascript/ql/src/Expressions/MissingAwait.ql | 3 +--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/javascript/ql/lib/semmle/javascript/internal/BindingInfo.qll b/javascript/ql/lib/semmle/javascript/internal/BindingInfo.qll
index bc3db9ef3a9..9250e337370 100644
--- a/javascript/ql/lib/semmle/javascript/internal/BindingInfo.qll
+++ b/javascript/ql/lib/semmle/javascript/internal/BindingInfo.qll
@@ -132,6 +132,11 @@ class TypeNameBindingNode extends NameResolution::Node {
* and enums and enum members have this property.
*/
predicate isSanitizingPrimitiveType() { TypeResolution::isSanitizingPrimitiveType(this) }
+
+ /**
+ * Holds if the given type is a Promise object. Does not hold for unions unless all parts of the union are promises.
+ */
+ predicate isPromiseType() { TypeResolution::isPromiseType(this) }
}
/**
diff --git a/javascript/ql/src/Expressions/MissingAwait.ql b/javascript/ql/src/Expressions/MissingAwait.ql
index a537156da01..851dcc00d57 100644
--- a/javascript/ql/src/Expressions/MissingAwait.ql
+++ b/javascript/ql/src/Expressions/MissingAwait.ql
@@ -11,7 +11,6 @@
*/
import javascript
-private import semmle.javascript.internal.TypeResolution
/**
* Holds if `call` is a call to an `async` function.
@@ -30,7 +29,7 @@ predicate isPromise(DataFlow::SourceNode node, boolean nullable) {
isAsyncCall(node, nullable)
or
not isAsyncCall(node, _) and
- TypeResolution::valueHasPromiseType(node.asExpr()) and
+ node.asExpr().getTypeBinding().isPromiseType() and
nullable = true
}
From 6d389c31c726b65f36482acff3dde709f0863f50 Mon Sep 17 00:00:00 2001
From: Asger F
Date: Mon, 2 Jun 2025 16:31:19 +0200
Subject: [PATCH 043/534] JS: Update an outdated QLDoc comment
---
javascript/ql/lib/semmle/javascript/Expr.qll | 2 --
1 file changed, 2 deletions(-)
diff --git a/javascript/ql/lib/semmle/javascript/Expr.qll b/javascript/ql/lib/semmle/javascript/Expr.qll
index d7fe610b4f1..f30e03cbdcb 100644
--- a/javascript/ql/lib/semmle/javascript/Expr.qll
+++ b/javascript/ql/lib/semmle/javascript/Expr.qll
@@ -1013,8 +1013,6 @@ class InvokeExpr extends @invokeexpr, Expr {
/**
* Gets the statically resolved target function, as determined by the TypeScript type system, if any.
*
- * This predicate is only populated for files extracted with full TypeScript extraction.
- *
* Note that the resolved function may be overridden in a subclass and thus is not
* necessarily the actual target of this invocation at runtime.
*/
From f5ac3fd611007e1fc46aaf9cc6d825b1bacba245 Mon Sep 17 00:00:00 2001
From: Asger F
Date: Tue, 3 Jun 2025 13:52:00 +0200
Subject: [PATCH 044/534] JS: Remove old metric-meta query TypedExprs.ql
This was used in the very old dist-compare tool, but has no use anymore
---
.../query-suite/not_included_in_qls.expected | 1 -
javascript/ql/src/meta/types/TypedExprs.ql | 17 -----------------
2 files changed, 18 deletions(-)
delete mode 100644 javascript/ql/src/meta/types/TypedExprs.ql
diff --git a/javascript/ql/integration-tests/query-suite/not_included_in_qls.expected b/javascript/ql/integration-tests/query-suite/not_included_in_qls.expected
index c80c3fc76da..0429922f7fc 100644
--- a/javascript/ql/integration-tests/query-suite/not_included_in_qls.expected
+++ b/javascript/ql/integration-tests/query-suite/not_included_in_qls.expected
@@ -146,4 +146,3 @@ ql/javascript/ql/src/meta/analysis-quality/UnresolvableImports.ql
ql/javascript/ql/src/meta/extraction-metrics/FileData.ql
ql/javascript/ql/src/meta/extraction-metrics/MissingMetrics.ql
ql/javascript/ql/src/meta/extraction-metrics/PhaseTimings.ql
-ql/javascript/ql/src/meta/types/TypedExprs.ql
diff --git a/javascript/ql/src/meta/types/TypedExprs.ql b/javascript/ql/src/meta/types/TypedExprs.ql
deleted file mode 100644
index 5e9efc349dc..00000000000
--- a/javascript/ql/src/meta/types/TypedExprs.ql
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * @name Typed expressions
- * @description The number of expressions for which the TypeScript extractor could
- * extract a type other than 'any'.
- * @kind metric
- * @metricType project
- * @metricAggregate sum
- * @tags meta
- * @id js/meta/typed-expressions
- */
-
-import javascript
-import meta.MetaMetrics
-
-predicate isProperType(Type t) { not t instanceof AnyType }
-
-select projectRoot(), count(Expr e | isProperType(e.getType()))
From ee9c4fa76341bd09414d7324778fc7cf9352d035 Mon Sep 17 00:00:00 2001
From: Asger F
Date: Mon, 2 Jun 2025 14:34:28 +0200
Subject: [PATCH 045/534] JS: Deprecate everything that depends on type
extraction
---
javascript/ql/lib/javascript.qll | 2 +-
.../lib/semmle/javascript/CanonicalNames.qll | 9 +-
.../ql/lib/semmle/javascript/Classes.qll | 2 +-
javascript/ql/lib/semmle/javascript/Expr.qll | 12 +-
.../ql/lib/semmle/javascript/Functions.qll | 4 +-
.../lib/semmle/javascript/TypeAnnotations.qll | 2 +-
.../ql/lib/semmle/javascript/TypeScript.qll | 117 +++++++++---------
7 files changed, 73 insertions(+), 75 deletions(-)
diff --git a/javascript/ql/lib/javascript.qll b/javascript/ql/lib/javascript.qll
index d75eed29b8e..46f35dee84f 100644
--- a/javascript/ql/lib/javascript.qll
+++ b/javascript/ql/lib/javascript.qll
@@ -47,7 +47,7 @@ import semmle.javascript.NodeJS
import semmle.javascript.NPM
import semmle.javascript.Paths
import semmle.javascript.Promises
-import semmle.javascript.CanonicalNames
+deprecated import semmle.javascript.CanonicalNames
import semmle.javascript.RangeAnalysis
import semmle.javascript.Regexp
import semmle.javascript.Routing
diff --git a/javascript/ql/lib/semmle/javascript/CanonicalNames.qll b/javascript/ql/lib/semmle/javascript/CanonicalNames.qll
index d83aeefdc9a..87f7c25b36d 100644
--- a/javascript/ql/lib/semmle/javascript/CanonicalNames.qll
+++ b/javascript/ql/lib/semmle/javascript/CanonicalNames.qll
@@ -1,6 +1,7 @@
/**
* Provides classes for working with name resolution of namespaces and types.
*/
+deprecated module;
import javascript
@@ -18,7 +19,7 @@ import javascript
*
* This class is only populated when full TypeScript extraction is enabled.
*/
-class CanonicalName extends @symbol {
+deprecated class CanonicalName extends @symbol {
/**
* Gets the parent of this canonical name, that is, the prefix of its qualified name.
*/
@@ -218,7 +219,7 @@ class CanonicalName extends @symbol {
/**
* The canonical name for a type.
*/
-class TypeName extends CanonicalName {
+deprecated class TypeName extends CanonicalName {
TypeName() {
exists(TypeReference ref | type_symbol(ref, this)) or
exists(TypeDefinition def | ast_node_symbol(def, this)) or
@@ -261,7 +262,7 @@ class TypeName extends CanonicalName {
/**
* The canonical name for a namespace.
*/
-class Namespace extends CanonicalName {
+deprecated class Namespace extends CanonicalName {
Namespace() {
this.getAChild().isExportedMember() or
exists(NamespaceDefinition def | ast_node_symbol(def, this)) or
@@ -309,7 +310,7 @@ class Namespace extends CanonicalName {
/**
* The canonical name for a function.
*/
-class CanonicalFunctionName extends CanonicalName {
+deprecated class CanonicalFunctionName extends CanonicalName {
CanonicalFunctionName() {
exists(Function fun | ast_node_symbol(fun, this)) or
exists(InvokeExpr invoke | ast_node_symbol(invoke, this))
diff --git a/javascript/ql/lib/semmle/javascript/Classes.qll b/javascript/ql/lib/semmle/javascript/Classes.qll
index f5877a78371..394ab791027 100644
--- a/javascript/ql/lib/semmle/javascript/Classes.qll
+++ b/javascript/ql/lib/semmle/javascript/Classes.qll
@@ -119,7 +119,7 @@ class ClassOrInterface extends @class_or_interface, TypeParameterized {
*
* Anonymous classes and interfaces do not have a canonical name.
*/
- TypeName getTypeName() { result.getADefinition() = this }
+ deprecated TypeName getTypeName() { result.getADefinition() = this }
/**
* Gets the ClassOrInterface corresponding to either a super type or an implemented interface.
diff --git a/javascript/ql/lib/semmle/javascript/Expr.qll b/javascript/ql/lib/semmle/javascript/Expr.qll
index f30e03cbdcb..f1177d1a773 100644
--- a/javascript/ql/lib/semmle/javascript/Expr.qll
+++ b/javascript/ql/lib/semmle/javascript/Expr.qll
@@ -176,7 +176,7 @@ class Expr extends @expr, ExprOrStmt, ExprOrType, AST::ValueNode {
* Has no result if the expression is in a JavaScript file or in a TypeScript
* file that was extracted without type information.
*/
- Type getType() { ast_node_type(this, result) }
+ deprecated Type getType() { ast_node_type(this, result) }
/**
* Holds if the syntactic context that the expression appears in relies on the expression
@@ -993,7 +993,7 @@ class InvokeExpr extends @invokeexpr, Expr {
*
* This predicate is only populated for files extracted with full TypeScript extraction.
*/
- CallSignatureType getResolvedSignature() { invoke_expr_signature(this, result) }
+ deprecated CallSignatureType getResolvedSignature() { invoke_expr_signature(this, result) }
/**
* Gets the index of the targeted call signature among the overload signatures
@@ -1008,7 +1008,7 @@ class InvokeExpr extends @invokeexpr, Expr {
*
* This predicate is only populated for files extracted with full TypeScript extraction.
*/
- CanonicalFunctionName getResolvedCalleeName() { ast_node_symbol(this, result) }
+ deprecated CanonicalFunctionName getResolvedCalleeName() { ast_node_symbol(this, result) }
/**
* Gets the statically resolved target function, as determined by the TypeScript type system, if any.
@@ -1016,11 +1016,7 @@ class InvokeExpr extends @invokeexpr, Expr {
* Note that the resolved function may be overridden in a subclass and thus is not
* necessarily the actual target of this invocation at runtime.
*/
- Function getResolvedCallee() {
- TypeResolution::callTarget(this, result)
- or
- result = this.getResolvedCalleeName().getImplementation()
- }
+ Function getResolvedCallee() { TypeResolution::callTarget(this, result) }
}
/**
diff --git a/javascript/ql/lib/semmle/javascript/Functions.qll b/javascript/ql/lib/semmle/javascript/Functions.qll
index 150dbea3f01..b72bfbc888e 100644
--- a/javascript/ql/lib/semmle/javascript/Functions.qll
+++ b/javascript/ql/lib/semmle/javascript/Functions.qll
@@ -434,12 +434,12 @@ class Function extends @function, Parameterized, TypeParameterized, StmtContaine
*
* This predicate is only populated for files extracted with full TypeScript extraction.
*/
- CanonicalFunctionName getCanonicalName() { ast_node_symbol(this, result) }
+ deprecated CanonicalFunctionName getCanonicalName() { ast_node_symbol(this, result) }
/**
* Gets the call signature of this function, as determined by the TypeScript compiler, if any.
*/
- CallSignatureType getCallSignature() { declared_function_signature(this, result) }
+ deprecated CallSignatureType getCallSignature() { declared_function_signature(this, result) }
}
/**
diff --git a/javascript/ql/lib/semmle/javascript/TypeAnnotations.qll b/javascript/ql/lib/semmle/javascript/TypeAnnotations.qll
index d9944b311ea..6d0a13c4a38 100644
--- a/javascript/ql/lib/semmle/javascript/TypeAnnotations.qll
+++ b/javascript/ql/lib/semmle/javascript/TypeAnnotations.qll
@@ -135,7 +135,7 @@ class TypeAnnotation extends @type_annotation, NodeInStmtContainer {
*
* Note that this has no result for JSDoc type annotations.
*/
- Type getType() { none() }
+ deprecated Type getType() { none() }
/**
* Gets the class referenced by this type annotation, if any.
diff --git a/javascript/ql/lib/semmle/javascript/TypeScript.qll b/javascript/ql/lib/semmle/javascript/TypeScript.qll
index ab670700c24..350efcea18e 100644
--- a/javascript/ql/lib/semmle/javascript/TypeScript.qll
+++ b/javascript/ql/lib/semmle/javascript/TypeScript.qll
@@ -32,7 +32,7 @@ class NamespaceDefinition extends Stmt, @namespace_definition, AST::ValueNode {
/**
* Gets the canonical name of the namespace being defined.
*/
- Namespace getNamespace() { result.getADefinition() = this }
+ deprecated Namespace getNamespace() { result.getADefinition() = this }
}
/**
@@ -112,12 +112,12 @@ class TypeDefinition extends AstNode, @type_definition {
/**
* Gets the canonical name of the type being defined.
*/
- TypeName getTypeName() { result.getADefinition() = this }
+ deprecated TypeName getTypeName() { result.getADefinition() = this }
/**
* Gets the type defined by this declaration.
*/
- Type getType() { ast_node_type(this.getIdentifier(), result) }
+ deprecated Type getType() { ast_node_type(this.getIdentifier(), result) }
override string getAPrimaryQlClass() { result = "TypeDefinition" }
}
@@ -269,7 +269,7 @@ class TypeAliasDeclaration extends @type_alias_declaration, TypeParameterized, S
/**
* Gets the canonical name of the type being defined.
*/
- TypeName getTypeName() { result.getADefinition() = this }
+ deprecated TypeName getTypeName() { result.getADefinition() = this }
override string getAPrimaryQlClass() { result = "TypeAliasDeclaration" }
}
@@ -549,7 +549,7 @@ class LocalNamespaceName extends @local_namespace_name, LexicalName {
/**
* Gets the canonical name of the namespace referenced by this name.
*/
- Namespace getNamespace() { result = this.getADeclaration().getNamespace() }
+ deprecated Namespace getNamespace() { result = this.getADeclaration().getNamespace() }
override DeclarationSpace getDeclarationSpace() { result = "namespace" }
}
@@ -569,7 +569,7 @@ class TypeExpr extends ExprOrType, @typeexpr, TypeAnnotation {
* Has no result if this occurs in a TypeScript file that was extracted
* without type information.
*/
- override Type getType() { ast_node_type(this, result) }
+ deprecated override Type getType() { ast_node_type(this, result) }
override Stmt getEnclosingStmt() { result = ExprOrType.super.getEnclosingStmt() }
@@ -693,7 +693,7 @@ class TypeAccess extends @typeaccess, TypeExpr, TypeRef {
/**
* Gets the canonical name of the type being accessed.
*/
- TypeName getTypeName() { ast_node_symbol(this, result) }
+ deprecated TypeName getTypeName() { ast_node_symbol(this, result) }
override string getAPrimaryQlClass() { result = "TypeAccess" }
}
@@ -1380,7 +1380,7 @@ class LocalNamespaceDecl extends VarDecl, NamespaceRef {
/**
* Gets the canonical name of the namespace being defined or aliased by this name.
*/
- Namespace getNamespace() { ast_node_symbol(this, result) }
+ deprecated Namespace getNamespace() { ast_node_symbol(this, result) }
}
/**
@@ -1398,7 +1398,7 @@ class NamespaceAccess extends TypeExpr, NamespaceRef, @namespace_access {
/**
* Gets the canonical name of the namespace being accessed.
*/
- Namespace getNamespace() { ast_node_symbol(this, result) }
+ deprecated Namespace getNamespace() { ast_node_symbol(this, result) }
override string getAPrimaryQlClass() { result = "NamespaceAccess" }
}
@@ -1507,7 +1507,7 @@ class EnumDeclaration extends NamespaceDefinition, @enum_declaration, AST::Value
/**
* Gets the canonical name of the type being defined.
*/
- TypeName getTypeName() { ast_node_symbol(this, result) }
+ deprecated TypeName getTypeName() { ast_node_symbol(this, result) }
/**
* Gets the local namespace name introduced by the enumeration, for use in
@@ -1595,7 +1595,7 @@ class EnumMember extends AstNode, @enum_member {
/**
* Gets the canonical name of the type defined by this enum member.
*/
- TypeName getTypeName() { ast_node_symbol(this, result) }
+ deprecated TypeName getTypeName() { ast_node_symbol(this, result) }
override string getAPrimaryQlClass() { result = "EnumMember" }
}
@@ -1776,7 +1776,7 @@ class TypeRootFolder extends Folder {
* For instance, there may be many AST nodes representing different uses of the
* `number` keyword, but there only exists one `number` type.
*/
-class Type extends @type {
+deprecated class Type extends @type {
/**
* Gets a string representation of this type.
*/
@@ -1975,7 +1975,7 @@ class Type extends @type {
/**
* A union type or intersection type, such as `string | number` or `T & U`.
*/
-class UnionOrIntersectionType extends Type, @union_or_intersection_type {
+deprecated class UnionOrIntersectionType extends Type, @union_or_intersection_type {
/**
* Gets the `i`th member of this union or intersection, starting at 0.
*/
@@ -1998,12 +1998,12 @@ class UnionOrIntersectionType extends Type, @union_or_intersection_type {
* Note that the `boolean` type is represented as the union `true | false`,
* but is still displayed as `boolean` in string representations.
*/
-class UnionType extends UnionOrIntersectionType, @union_type { }
+deprecated class UnionType extends UnionOrIntersectionType, @union_type { }
/**
* An intersection type, such as `T & {x: number}`.
*/
-class IntersectionType extends UnionOrIntersectionType, @intersection_type { }
+deprecated class IntersectionType extends UnionOrIntersectionType, @intersection_type { }
/**
* A type that describes a JavaScript `Array` object.
@@ -2016,7 +2016,7 @@ class IntersectionType extends UnionOrIntersectionType, @intersection_type { }
* Foreign array-like objects such as `HTMLCollection` are not normal JavaScript arrays,
* and their corresponding types are not considered array types either.
*/
-class ArrayType extends Type {
+deprecated class ArrayType extends Type {
ArrayType() {
this instanceof @tuple_type or
this.(TypeReference).hasQualifiedName("Array") or
@@ -2032,7 +2032,7 @@ class ArrayType extends Type {
/**
* An array type such as `Array`, or equivalently, `string[]`.
*/
-class PlainArrayType extends ArrayType, TypeReference {
+deprecated class PlainArrayType extends ArrayType, TypeReference {
PlainArrayType() { this.hasQualifiedName("Array") }
override Type getNumberIndexType() { result = this.getTypeArgument(0) }
@@ -2041,14 +2041,14 @@ class PlainArrayType extends ArrayType, TypeReference {
/**
* A read-only array type such as `ReadonlyArray`.
*/
-class ReadonlyArrayType extends ArrayType, TypeReference {
+deprecated class ReadonlyArrayType extends ArrayType, TypeReference {
ReadonlyArrayType() { this.hasQualifiedName("ReadonlyArray") }
}
/**
* A tuple type, such as `[number, string]`.
*/
-class TupleType extends ArrayType, @tuple_type {
+deprecated class TupleType extends ArrayType, @tuple_type {
/**
* Gets the `i`th member of this tuple type, starting at 0.
*/
@@ -2104,32 +2104,32 @@ class TupleType extends ArrayType, @tuple_type {
/**
* The predefined `any` type.
*/
-class AnyType extends Type, @any_type { }
+deprecated class AnyType extends Type, @any_type { }
/**
* The predefined `unknown` type.
*/
-class UnknownType extends Type, @unknown_type { }
+deprecated class UnknownType extends Type, @unknown_type { }
/**
* The predefined `string` type.
*/
-class StringType extends Type, @string_type { }
+deprecated class StringType extends Type, @string_type { }
/**
* The predefined `number` type.
*/
-class NumberType extends Type, @number_type { }
+deprecated class NumberType extends Type, @number_type { }
/**
* The predefined `bigint` type.
*/
-class BigIntType extends Type, @bigint_type { }
+deprecated class BigIntType extends Type, @bigint_type { }
/**
* A boolean, number, or string literal type.
*/
-class LiteralType extends Type, @literal_type {
+deprecated class LiteralType extends Type, @literal_type {
/**
* Gets the string value of this literal.
*/
@@ -2139,7 +2139,7 @@ class LiteralType extends Type, @literal_type {
/**
* The boolean literal type `true` or `false`.
*/
-class BooleanLiteralType extends LiteralType, @boolean_literal_type {
+deprecated class BooleanLiteralType extends LiteralType, @boolean_literal_type {
/**
* Gets the boolean value represented by this type.
*/
@@ -2153,7 +2153,7 @@ class BooleanLiteralType extends LiteralType, @boolean_literal_type {
/**
* A number literal as a static type.
*/
-class NumberLiteralType extends LiteralType, @number_literal_type {
+deprecated class NumberLiteralType extends LiteralType, @number_literal_type {
override string getStringValue() { type_literal_value(this, result) }
/**
@@ -2170,14 +2170,14 @@ class NumberLiteralType extends LiteralType, @number_literal_type {
/**
* A string literal as a static type.
*/
-class StringLiteralType extends LiteralType, @string_literal_type {
+deprecated class StringLiteralType extends LiteralType, @string_literal_type {
override string getStringValue() { type_literal_value(this, result) }
}
/**
* A bigint literal as a static type.
*/
-class BigIntLiteralType extends LiteralType {
+deprecated class BigIntLiteralType extends LiteralType {
override string getStringValue() { type_literal_value(this, result) }
/**
@@ -2194,7 +2194,7 @@ class BigIntLiteralType extends LiteralType {
/**
* The `boolean` type, internally represented as the union type `true | false`.
*/
-class BooleanType extends UnionType {
+deprecated class BooleanType extends UnionType {
BooleanType() {
this.getAnElementType() instanceof @true_type and
this.getAnElementType() instanceof @false_type and
@@ -2205,7 +2205,7 @@ class BooleanType extends UnionType {
/**
* The `string` type or a string literal type.
*/
-class StringLikeType extends Type {
+deprecated class StringLikeType extends Type {
StringLikeType() {
this instanceof StringType or
this instanceof StringLiteralType
@@ -2215,7 +2215,7 @@ class StringLikeType extends Type {
/**
* The `number` type or a number literal type.
*/
-class NumberLikeType extends Type {
+deprecated class NumberLikeType extends Type {
NumberLikeType() {
this instanceof NumberType or
this instanceof NumberLiteralType
@@ -2225,7 +2225,7 @@ class NumberLikeType extends Type {
/**
* The `boolean`, `true,` or `false` type.
*/
-class BooleanLikeType extends Type {
+deprecated class BooleanLikeType extends Type {
BooleanLikeType() {
this instanceof BooleanType or
this instanceof BooleanLiteralType
@@ -2235,37 +2235,37 @@ class BooleanLikeType extends Type {
/**
* The `void` type.
*/
-class VoidType extends Type, @void_type { }
+deprecated class VoidType extends Type, @void_type { }
/**
* The `undefined` type.
*/
-class UndefinedType extends Type, @undefined_type { }
+deprecated class UndefinedType extends Type, @undefined_type { }
/**
* The `null` type.
*/
-class NullType extends Type, @null_type { }
+deprecated class NullType extends Type, @null_type { }
/**
* The `never` type.
*/
-class NeverType extends Type, @never_type { }
+deprecated class NeverType extends Type, @never_type { }
/**
* The `symbol` type or a specific `unique symbol` type.
*/
-class SymbolType extends Type, @symbol_type { }
+deprecated class SymbolType extends Type, @symbol_type { }
/**
* The `symbol` type.
*/
-class PlainSymbolType extends SymbolType, @plain_symbol_type { }
+deprecated class PlainSymbolType extends SymbolType, @plain_symbol_type { }
/**
* A `unique symbol` type.
*/
-class UniqueSymbolType extends SymbolType, @unique_symbol_type {
+deprecated class UniqueSymbolType extends SymbolType, @unique_symbol_type {
/**
* Gets the canonical name of the variable exposing the symbol.
*/
@@ -2294,12 +2294,12 @@ class UniqueSymbolType extends SymbolType, @unique_symbol_type {
/**
* The `object` type.
*/
-class ObjectKeywordType extends Type, @objectkeyword_type { }
+deprecated class ObjectKeywordType extends Type, @objectkeyword_type { }
/**
* A type that refers to a class, interface, enum, or enum member.
*/
-class TypeReference extends Type, @type_reference {
+deprecated class TypeReference extends Type, @type_reference {
/**
* Gets the canonical name of the type being referenced.
*/
@@ -2352,7 +2352,7 @@ class TypeReference extends Type, @type_reference {
/**
* A type that refers to a class, possibly with type arguments.
*/
-class ClassType extends TypeReference {
+deprecated class ClassType extends TypeReference {
ClassDefinition declaration;
ClassType() { declaration = this.getADefinition() }
@@ -2366,7 +2366,7 @@ class ClassType extends TypeReference {
/**
* A type that refers to an interface, possibly with type arguents.
*/
-class InterfaceType extends TypeReference {
+deprecated class InterfaceType extends TypeReference {
InterfaceDeclaration declaration;
InterfaceType() { declaration = this.getADefinition() }
@@ -2380,7 +2380,7 @@ class InterfaceType extends TypeReference {
/**
* A type that refers to an enum.
*/
-class EnumType extends TypeReference {
+deprecated class EnumType extends TypeReference {
EnumDeclaration declaration;
EnumType() { declaration = this.getADefinition() }
@@ -2394,7 +2394,7 @@ class EnumType extends TypeReference {
/**
* A type that refers to the value of an enum member.
*/
-class EnumLiteralType extends TypeReference {
+deprecated class EnumLiteralType extends TypeReference {
EnumMember declaration;
EnumLiteralType() { declaration = this.getADefinition() }
@@ -2408,7 +2408,7 @@ class EnumLiteralType extends TypeReference {
/**
* A type that refers to a type alias.
*/
-class TypeAliasReference extends TypeReference {
+deprecated class TypeAliasReference extends TypeReference {
TypeAliasReference() { type_alias(this, _) }
/**
@@ -2422,12 +2422,12 @@ class TypeAliasReference extends TypeReference {
/**
* An anonymous interface type, such as `{ x: number }`.
*/
-class AnonymousInterfaceType extends Type, @object_type { }
+deprecated class AnonymousInterfaceType extends Type, @object_type { }
/**
* A type that refers to a type variable.
*/
-class TypeVariableType extends Type, @typevariable_type {
+deprecated class TypeVariableType extends Type, @typevariable_type {
/**
* Gets a syntactic declaration of this type variable.
*
@@ -2467,7 +2467,7 @@ class TypeVariableType extends Type, @typevariable_type {
/**
* A type that refers to a type variable declared on a class, interface or function.
*/
-class CanonicalTypeVariableType extends TypeVariableType, @canonical_type_variable_type {
+deprecated class CanonicalTypeVariableType extends TypeVariableType, @canonical_type_variable_type {
override TypeName getHostType() { result = this.getCanonicalName().getParent() }
override CanonicalName getCanonicalName() { type_symbol(this, result) }
@@ -2487,7 +2487,7 @@ class CanonicalTypeVariableType extends TypeVariableType, @canonical_type_variab
* - `(x: T) => T`
* - `(x: S, y: T) => T`.
*/
-class LexicalTypeVariableType extends TypeVariableType, @lexical_type_variable_type {
+deprecated class LexicalTypeVariableType extends TypeVariableType, @lexical_type_variable_type {
override string getName() {
types(this, _, result) // The toString value contains the name.
}
@@ -2504,7 +2504,7 @@ class LexicalTypeVariableType extends TypeVariableType, @lexical_type_variable_t
* }
* ```
*/
-class ThisType extends Type, @this_type {
+deprecated class ThisType extends Type, @this_type {
/**
* Gets the type containing the `this` type.
*/
@@ -2517,7 +2517,7 @@ class ThisType extends Type, @this_type {
* The type of a named value, `typeof X`, typically denoting the type of
* a class constructor, namespace object, enum object, or module object.
*/
-class TypeofType extends Type, @typeof_type {
+deprecated class TypeofType extends Type, @typeof_type {
/**
* Gets the canonical name of the named value.
*/
@@ -2592,7 +2592,7 @@ module SignatureKind {
/**
* A function or constructor signature in a TypeScript type.
*/
-class CallSignatureType extends @signature_type {
+deprecated class CallSignatureType extends @signature_type {
/**
* Gets a value indicating if this is a function or constructor signature.
*/
@@ -2741,12 +2741,13 @@ class CallSignatureType extends @signature_type {
/**
* A function call signature in a type, that is, a signature without the `new` keyword.
*/
-class FunctionCallSignatureType extends CallSignatureType, @function_signature_type { }
+deprecated class FunctionCallSignatureType extends CallSignatureType, @function_signature_type { }
/**
* A constructor call signature in a type, that is, a signature with the `new` keyword.
*/
-class ConstructorCallSignatureType extends CallSignatureType, @constructor_signature_type { }
+deprecated class ConstructorCallSignatureType extends CallSignatureType, @constructor_signature_type
+{ }
/**
* A type name that defines a promise.
@@ -2756,7 +2757,7 @@ class ConstructorCallSignatureType extends CallSignatureType, @constructor_signa
* - It has one type parameter, say, `T`
* - It has a `then` method whose first argument is a callback that takes a `T` as argument.
*/
-private class PromiseTypeName extends TypeName {
+deprecated private class PromiseTypeName extends TypeName {
PromiseTypeName() {
// The name must suggest it is a promise.
this.getName().matches(["%Promise", "%PromiseLike", "%Thenable", "%Deferred"]) and
@@ -2780,7 +2781,7 @@ private class PromiseTypeName extends TypeName {
* This includes types whose name and `then` method signature suggest it is a promise,
* such as `PromiseLike` and `Thenable`.
*/
-class PromiseType extends TypeReference {
+deprecated class PromiseType extends TypeReference {
PromiseType() {
this.getNumTypeArgument() = 1 and
this.getTypeName() instanceof PromiseTypeName
From f5f12c2f81640db20c082d020be397098d928d7c Mon Sep 17 00:00:00 2001
From: Asger F
Date: Mon, 2 Jun 2025 16:31:46 +0200
Subject: [PATCH 046/534] JS: Delete or simplify TypeScript type-specific tests
---
.../TypeScript/ArrayTypes/tests.expected | 17 -
.../TypeScript/ArrayTypes/tests.ql | 11 -
.../TypeScript/ArrayTypes/tsconfig.json | 1 -
.../TypeScript/ArrayTypes/tst.ts | 19 -
.../TypeScript/BaseTypes/BaseTypes.expected | 15 -
.../TypeScript/BaseTypes/BaseTypes.ql | 4 -
.../TypeScript/BaseTypes/SelfTypes.expected | 17 -
.../TypeScript/BaseTypes/SelfTypes.ql | 4 -
.../TypeScript/BaseTypes/tsconfig.json | 1 -
.../library-tests/TypeScript/BaseTypes/tst.ts | 39 -
.../TypeScript/BigInts/tests.expected | 7 -
.../library-tests/TypeScript/BigInts/tests.ql | 4 -
.../CallResolution/CallResolution.expected | 24 -
.../CallResolution/CallResolution.ql | 4 -
.../CallResolution/CallTarget.expected | 36 -
.../TypeScript/CallResolution/CallTarget.ql | 11 -
.../TypeScript/CallResolution/tsconfig.json | 1 -
.../TypeScript/CallResolution/tst.ts | 85 -
.../CallSignatureTypes/test.expected | 131 -
.../TypeScript/CallSignatureTypes/test.ql | 41 -
.../CallSignatureTypes/tsconfig.json | 1 -
.../TypeScript/CallSignatureTypes/tst.ts | 65 -
.../DeclarationFiles/TypeResolution.expected | 8 -
.../DeclarationFiles/TypeResolution.ql | 4 -
.../TypeScript/EmbeddedInScript/Test.expected | 28 -
.../TypeScript/EmbeddedInScript/Test.ql | 4 -
.../TypeScript/ExpansiveTypes/Types.expected | 77 -
.../TypeScript/ExpansiveTypes/Types.ql | 4 -
.../TypeScript/ExpansiveTypes/dummy.ts | 1 -
.../ExpansiveTypes/expansive_by_inference.ts | 8 -
.../ExpansiveTypes/expansive_class.ts | 5 -
.../expansive_object_literal.ts | 7 -
.../ExpansiveTypes/expansive_signature.ts | 25 -
.../ExpansiveTypes/leading_into_expansion.ts | 13 -
.../TypeScript/ExpansiveTypes/mutual.ts | 17 -
.../ExpansiveTypes/mutual_multigraph.ts | 24 -
.../ExpansiveTypes/shared_non_expansive.ts | 12 -
.../TypeScript/ExpansiveTypes/simple.ts | 5 -
.../ExpansiveTypes/through_non_expansive.ts | 10 -
.../TypeScript/ExpansiveTypes/tsconfig.json | 1 -
.../ExpansiveTypes/used_from_expansion.ts | 15 -
.../ExternalBaseTypes/BaseTypes.expected | 3 -
.../TypeScript/ExternalBaseTypes/BaseTypes.ql | 5 -
.../node_modules/@types/mylib/index.d.ts | 4 -
.../TypeScript/ExternalBaseTypes/options | 1 -
.../ExternalBaseTypes/tsconfig.json | 5 -
.../TypeScript/ExternalBaseTypes/tst.ts | 3 -
.../TypeScript/ExternalTypes/augmentation.ts | 9 -
.../ExternalTypes/client_esmodule.ts | 16 -
.../ExternalTypes/client_esmodule_extra.ts | 7 -
.../ExternalTypes/client_legacy_global.ts | 3 -
.../ExternalTypes/client_legacy_module.ts | 3 -
.../ExternalTypes/client_modern_global.ts | 3 -
.../ExternalTypes/client_modern_module.ts | 3 -
.../node_modules/@types/esmodule/index.d.ts | 10 -
.../@types/esmodule/otherfile.d.ts | 1 -
.../@types/esmodule/util/extra.d.ts | 1 -
.../@types/esmodule/util/index.d.ts | 1 -
.../node_modules/@types/legacy/index.d.ts | 13 -
.../node_modules/@types/modern/index.d.ts | 12 -
.../TypeScript/ExternalTypes/options | 1 -
.../TypeScript/ExternalTypes/tests.expected | 28 -
.../TypeScript/ExternalTypes/tests.ql | 26 -
.../TypeScript/ExternalTypes/tsconfig.json | 5 -
.../HasUnderlyingType.expected | 10 -
.../HasUnderlyingType/HasUnderlyingType.ql | 9 -
.../TypeScript/HasUnderlyingType/foo.ts | 5 -
.../HasUnderlyingType/tsconfig.json | 3 -
.../TypeScript/HasUnderlyingType/tst.ts | 9 -
.../ImportOwnPackage/TypeNames.expected | 22 -
.../TypeScript/ImportOwnPackage/TypeNames.ql | 11 -
.../TypeScript/ImportOwnPackage/bar/client.ts | 13 -
.../TypeScript/ImportOwnPackage/foo/index.ts | 9 -
.../ImportOwnPackage/foo/package.json | 3 -
.../TypeScript/ImportOwnPackage/tsconfig.json | 3 -
.../TypeScript/IndexTypes/test.expected | 2 -
.../TypeScript/IndexTypes/test.ql | 3 -
.../TypeScript/IndexTypes/tsconfig.json | 1 -
.../TypeScript/IndexTypes/tst.ts | 8 -
.../InfiniteTypes/recursiveMappedType.ts | 8 -
.../TypeScript/InfiniteTypes/test.expected | 2 -
.../TypeScript/InfiniteTypes/test.ql | 4 -
.../TypeScript/InfiniteTypes/tsconfig.json | 3 -
.../LexicalTypes/TypeReferences.expected | 16 -
.../TypeScript/LexicalTypes/TypeReferences.ql | 4 -
.../TypeScript/LexicalTypes/bar.ts | 12 -
.../TypeScript/LexicalTypes/dummy.ts | 1 -
.../TypeScript/LexicalTypes/foo.ts | 20 -
.../TypeScript/LexicalTypes/tsconfig.json | 1 -
.../LiteralTypes/FloatLiteralTypes.expected | 4 -
.../LiteralTypes/FloatLiteralTypes.ql | 4 -
.../LiteralTypes/IntLiteralTypes.expected | 2 -
.../LiteralTypes/IntLiteralTypes.ql | 4 -
.../LiteralTypes/LiteralTypes.expected | 11 -
.../TypeScript/LiteralTypes/LiteralTypes.ql | 4 -
.../TypeScript/LiteralTypes/tsconfig.json | 3 -
.../TypeScript/LiteralTypes/tst.ts | 12 -
.../TypeScript/NestedLiteral/test.expected | 36 -
.../TypeScript/NestedLiteral/test.ql | 4 -
.../TypeScript/NestedLiteral/tsconfig.json | 1 -
.../TypeScript/NestedLiteral/tst.ts | 30 -
.../TypeScript/Nullability/Types.expected | 10 -
.../TypeScript/Nullability/Types.ql | 5 -
.../TypeScript/Nullability/tsconfig.json | 6 -
.../TypeScript/Nullability/tst.ts | 10 -
.../TypeScript/PathMapping/Imports.expected | 11 -
.../TypeScript/PathMapping/Imports.ql | 6 -
.../TypeScript/PathMapping/src/lib/foo.ts | 3 -
.../TypeScript/PathMapping/test/test_foo.ts | 6 -
.../TypeScript/PathMapping/tsconfig.json | 9 -
.../PromiseType/DefinitelyTyped-LICENSE | 8 -
.../PromiseType/PromiseType.expected | 9 -
.../TypeScript/PromiseType/PromiseType.ql | 12 -
.../TypeScript/PromiseType/QDeferred.expected | 1 -
.../TypeScript/PromiseType/QDeferred.ql | 5 -
.../PromiseType/es6-promise-LICENSE | 19 -
.../TypeScript/PromiseType/es6-promise.d.ts | 9 -
.../TypeScript/PromiseType/jquery.d.ts | 41 -
.../node_modules/@types/q/index.d.ts | 27 -
.../TypeScript/PromiseType/promise-LICENSE | 19 -
.../TypeScript/PromiseType/promise.d.ts | 11 -
.../TypeScript/PromiseType/tsconfig.json | 3 -
.../TypeScript/PromiseType/tst.ts | 34 -
.../Namespaces.expected | 33 -
.../QualifiedNameResolution/Namespaces.ql | 4 -
.../ResolveNamespace.expected | 31 -
.../ResolveNamespace.ql | 4 -
.../ResolveTypeName.expected | 27 -
.../ResolveTypeName.ql | 4 -
.../QualifiedNameResolution/ambient.ts | 5 -
.../QualifiedNameResolution/dummy.ts | 1 -
.../QualifiedNameResolution/enums.ts | 10 -
.../export-class-client-renamed.ts | 3 -
.../export-class-client.ts | 3 -
.../QualifiedNameResolution/export-class.ts | 3 -
.../export-default-type-client.ts | 3 -
.../export-default-type.ts | 5 -
.../export-qualified-client.ts | 3 -
.../export-qualified.ts | 7 -
.../export-specifiers-client.ts | 6 -
.../export-specifiers.ts | 13 -
.../QualifiedNameResolution/global.ts | 5 -
.../import-in-namespace.ts | 11 -
.../namespaces-client.ts | 6 -
.../QualifiedNameResolution/namespaces.ts | 43 -
.../QualifiedNameResolution/otherlib.ts | 1 -
.../reexport-all-client.ts | 11 -
.../QualifiedNameResolution/reexport-all.ts | 3 -
.../reexport-named-client.ts | 11 -
.../QualifiedNameResolution/reexport-named.ts | 2 -
.../QualifiedNameResolution/tsconfig.json | 1 -
.../RegressionTests/AllowJs/main.ts | 2 -
.../RegressionTests/AllowJs/test.expected | 5 -
.../RegressionTests/AllowJs/test.ql | 4 -
.../RegressionTests/AllowJs/tsconfig.json | 6 -
.../TypeScript/RegressionTests/AllowJs/tst.js | 6 -
.../RegressionTests/EmptyName/test.expected | 5 +-
.../RegressionTests/EmptyName/test.ql | 3 +-
.../ExportEqualsExpr/test.expected | 8 +-
.../RegressionTests/ExportEqualsExpr/test.ql | 3 +-
.../GenericTypeAlias/test.expected | 15 -
.../RegressionTests/GenericTypeAlias/test.ql | 8 -
.../GenericTypeAlias/tsconfig.json | 3 -
.../RegressionTests/GenericTypeAlias/tst.ts | 5 -
.../RegressionTests/ImportSelf/test.expected | 4 +-
.../RegressionTests/ImportSelf/test.ql | 4 +-
.../RecursiveTypeAlias/Test.expected | 1 +
.../RecursiveTypeAlias/Test.ql | 3 +-
.../SemicolonInName/test.expected | 3 +-
.../RegressionTests/SemicolonInName/test.ql | 3 +-
.../node_modules/@types/foo/index.d.ts | 1 -
.../TraceResolution/test.expected | 4 -
.../RegressionTests/TraceResolution/test.ql | 4 -
.../RegressionTests/TraceResolution/test.ts | 3 -
.../TraceResolution/tsconfig.json | 6 -
.../TypeRootFile/test.expected | 3 -
.../RegressionTests/TypeRootFile/test.ql | 4 -
.../TypeRootFile/tsconfig.json | 6 -
.../RegressionTests/TypeRootFile/tst.ts | 1 -
.../TypeRootFile/typeroot.d.ts | 0
.../TypeScript/TSConfigReferences/src/main.ts | 4 -
.../TSConfigReferences/test.expected | 11 -
.../TypeScript/TSConfigReferences/test.ql | 5 -
.../TSConfigReferences/tsconfig.foo.json | 9 -
.../TSConfigReferences/tsconfig.json | 7 -
.../TypeAliases/TypeAliases.expected | 36 -
.../TypeScript/TypeAliases/TypeAliases.ql | 8 -
.../TypeVariableTypes/tests.expected | 28 -
.../TypeScript/TypeVariableTypes/tests.ql | 43 -
.../TypeVariableTypes/tsconfig.json | 1 -
.../TypeScript/TypeVariableTypes/tst.ts | 34 -
.../TypeScript/Types/badTypes.ts | 6 -
.../TypeScript/Types/boolean-type.ts | 15 -
.../library-tests/TypeScript/Types/dummy.ts | 4 -
.../TypeScript/Types/middle-rest.ts | 3 -
.../TypeScript/Types/printAst.expected | 6042 -----------------
.../TypeScript/Types/printAst.ql | 2 -
.../TypeScript/Types/something.json | 3 -
.../TypeScript/Types/tests.expected | 1545 -----
.../library-tests/TypeScript/Types/tests.ql | 45 -
.../TypeScript/Types/tsconfig.json | 9 -
.../library-tests/TypeScript/Types/tst.ts | 520 --
.../TypeScript/Types/tstModuleCJS.cts | 3 -
.../TypeScript/Types/tstModuleES.mts | 3 -
.../TypeScript/Types/tstSuffixA.ts | 3 -
.../TypeScript/Types/tstSuffixB.ios.ts | 3 -
.../TypeScript/Types/tstSuffixB.ts | 3 -
.../TypeScript/Types/type_alias.ts | 27 -
.../Types/type_definition_objects.ts | 10 -
.../TypeScript/Types/type_definitions.ts | 22 -
210 files changed, 10 insertions(+), 10356 deletions(-)
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ArrayTypes/tests.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ArrayTypes/tests.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ArrayTypes/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ArrayTypes/tst.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/BaseTypes/BaseTypes.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/BaseTypes/BaseTypes.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/BaseTypes/SelfTypes.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/BaseTypes/SelfTypes.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/BaseTypes/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/BaseTypes/tst.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/CallResolution/CallResolution.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/CallResolution/CallResolution.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/CallResolution/CallTarget.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/CallResolution/CallTarget.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/CallResolution/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/CallResolution/tst.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/CallSignatureTypes/test.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/CallSignatureTypes/test.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/CallSignatureTypes/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/CallSignatureTypes/tst.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/DeclarationFiles/TypeResolution.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/DeclarationFiles/TypeResolution.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/Types.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/Types.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/dummy.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/expansive_by_inference.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/expansive_class.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/expansive_object_literal.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/expansive_signature.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/leading_into_expansion.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/mutual.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/mutual_multigraph.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/shared_non_expansive.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/simple.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/through_non_expansive.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/used_from_expansion.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/BaseTypes.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/BaseTypes.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/node_modules/@types/mylib/index.d.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/options
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/tst.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalTypes/augmentation.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_esmodule.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_esmodule_extra.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_legacy_global.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_legacy_module.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_modern_global.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_modern_module.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/esmodule/index.d.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/esmodule/otherfile.d.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/esmodule/util/extra.d.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/esmodule/util/index.d.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/legacy/index.d.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/modern/index.d.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalTypes/options
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalTypes/tests.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalTypes/tests.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ExternalTypes/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/HasUnderlyingType.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/HasUnderlyingType.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/foo.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/tst.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/TypeNames.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/TypeNames.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/bar/client.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/foo/index.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/foo/package.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/IndexTypes/test.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/IndexTypes/test.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/IndexTypes/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/IndexTypes/tst.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/InfiniteTypes/recursiveMappedType.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/InfiniteTypes/test.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/InfiniteTypes/test.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/InfiniteTypes/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/LexicalTypes/TypeReferences.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/LexicalTypes/TypeReferences.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/LexicalTypes/bar.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/LexicalTypes/dummy.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/LexicalTypes/foo.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/LexicalTypes/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/LiteralTypes/FloatLiteralTypes.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/LiteralTypes/FloatLiteralTypes.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/LiteralTypes/IntLiteralTypes.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/LiteralTypes/IntLiteralTypes.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/LiteralTypes/LiteralTypes.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/LiteralTypes/LiteralTypes.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/LiteralTypes/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/LiteralTypes/tst.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/NestedLiteral/test.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/NestedLiteral/test.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/NestedLiteral/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/NestedLiteral/tst.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Nullability/Types.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Nullability/Types.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Nullability/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Nullability/tst.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/PathMapping/Imports.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/PathMapping/Imports.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/PathMapping/src/lib/foo.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/PathMapping/test/test_foo.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/PathMapping/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/PromiseType/DefinitelyTyped-LICENSE
delete mode 100644 javascript/ql/test/library-tests/TypeScript/PromiseType/PromiseType.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/PromiseType/PromiseType.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/PromiseType/QDeferred.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/PromiseType/QDeferred.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/PromiseType/es6-promise-LICENSE
delete mode 100644 javascript/ql/test/library-tests/TypeScript/PromiseType/es6-promise.d.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/PromiseType/jquery.d.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/PromiseType/node_modules/@types/q/index.d.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/PromiseType/promise-LICENSE
delete mode 100644 javascript/ql/test/library-tests/TypeScript/PromiseType/promise.d.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/PromiseType/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/PromiseType/tst.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/Namespaces.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/Namespaces.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/ResolveNamespace.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/ResolveNamespace.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/ResolveTypeName.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/ResolveTypeName.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/ambient.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/dummy.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/enums.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/export-class-client-renamed.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/export-class-client.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/export-class.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/export-default-type-client.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/export-default-type.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/export-qualified-client.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/export-qualified.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/export-specifiers-client.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/export-specifiers.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/global.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/import-in-namespace.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/namespaces-client.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/namespaces.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/otherlib.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/reexport-all-client.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/reexport-all.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/reexport-named-client.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/reexport-named.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/QualifiedNameResolution/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/RegressionTests/AllowJs/main.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/RegressionTests/AllowJs/test.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/RegressionTests/AllowJs/test.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/RegressionTests/AllowJs/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/RegressionTests/AllowJs/tst.js
delete mode 100644 javascript/ql/test/library-tests/TypeScript/RegressionTests/GenericTypeAlias/test.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/RegressionTests/GenericTypeAlias/test.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/RegressionTests/GenericTypeAlias/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/RegressionTests/GenericTypeAlias/tst.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/RegressionTests/TraceResolution/node_modules/@types/foo/index.d.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/RegressionTests/TraceResolution/test.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/RegressionTests/TraceResolution/test.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/RegressionTests/TraceResolution/test.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/RegressionTests/TraceResolution/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/RegressionTests/TypeRootFile/test.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/RegressionTests/TypeRootFile/test.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/RegressionTests/TypeRootFile/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/RegressionTests/TypeRootFile/tst.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/RegressionTests/TypeRootFile/typeroot.d.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/TSConfigReferences/src/main.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/TSConfigReferences/test.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/TSConfigReferences/test.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/TSConfigReferences/tsconfig.foo.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/TSConfigReferences/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/TypeVariableTypes/tests.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/TypeVariableTypes/tests.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/TypeVariableTypes/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/TypeVariableTypes/tst.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Types/badTypes.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Types/boolean-type.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Types/dummy.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Types/middle-rest.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Types/printAst.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Types/printAst.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Types/something.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Types/tests.expected
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Types/tests.ql
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Types/tsconfig.json
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Types/tst.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Types/tstModuleCJS.cts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Types/tstModuleES.mts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Types/tstSuffixA.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Types/tstSuffixB.ios.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Types/tstSuffixB.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Types/type_alias.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Types/type_definition_objects.ts
delete mode 100644 javascript/ql/test/library-tests/TypeScript/Types/type_definitions.ts
diff --git a/javascript/ql/test/library-tests/TypeScript/ArrayTypes/tests.expected b/javascript/ql/test/library-tests/TypeScript/ArrayTypes/tests.expected
deleted file mode 100644
index dac5bb14db4..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ArrayTypes/tests.expected
+++ /dev/null
@@ -1,17 +0,0 @@
-arrayTypes
-| [number, string] | `string \| number` |
-| number[] | `number` |
-| readonly T[] | `T` |
-| readonly number[] | `number` |
-| readonly number[][] | `number[]` |
-numberIndexTypes
-| NumberIndexable | object |
-| [number, string] | string \| number |
-| number[] | number |
-| readonly T[] | T |
-| readonly number[] | number |
-| readonly number[][] | number[] |
-| string | string |
-stringIndexTypes
-| StringIndexable | object |
-tupleTypes
diff --git a/javascript/ql/test/library-tests/TypeScript/ArrayTypes/tests.ql b/javascript/ql/test/library-tests/TypeScript/ArrayTypes/tests.ql
deleted file mode 100644
index 907a5d78639..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ArrayTypes/tests.ql
+++ /dev/null
@@ -1,11 +0,0 @@
-import javascript
-
-query predicate arrayTypes(ArrayType array, string elem) {
- elem = "`" + array.getArrayElementType() + "`"
-}
-
-query predicate numberIndexTypes(Type type, Type numType) { type.getNumberIndexType() = numType }
-
-query predicate stringIndexTypes(Type type, Type strType) { type.getStringIndexType() = strType }
-
-query predicate tupleTypes(TupleType type, Type arrType) { arrType = type.getUnderlyingArrayType() }
diff --git a/javascript/ql/test/library-tests/TypeScript/ArrayTypes/tsconfig.json b/javascript/ql/test/library-tests/TypeScript/ArrayTypes/tsconfig.json
deleted file mode 100644
index 9e26dfeeb6e..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ArrayTypes/tsconfig.json
+++ /dev/null
@@ -1 +0,0 @@
-{}
\ No newline at end of file
diff --git a/javascript/ql/test/library-tests/TypeScript/ArrayTypes/tst.ts b/javascript/ql/test/library-tests/TypeScript/ArrayTypes/tst.ts
deleted file mode 100644
index 98ca0c2eb21..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ArrayTypes/tst.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-let plain: number[];
-let readonly: ReadonlyArray;
-let tuple: [number, string];
-
-interface NumberIndexable {
- length: number;
- [n: number]: object;
-}
-
-interface StringIndexable {
- length: number;
- [n: string]: object;
-}
-
-let numberIndexable: NumberIndexable;
-let stringIndexable: StringIndexable;
-
-let readonlySyntax: readonly number[];
-let readonlySyntax2: readonly number[][];
diff --git a/javascript/ql/test/library-tests/TypeScript/BaseTypes/BaseTypes.expected b/javascript/ql/test/library-tests/TypeScript/BaseTypes/BaseTypes.expected
deleted file mode 100644
index b6e9c06ec57..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/BaseTypes/BaseTypes.expected
+++ /dev/null
@@ -1,15 +0,0 @@
-| CEverything | CGenericBase |
-| CEverything | IBase |
-| CEverything | IGenericSub |
-| CGenericSub | CGenericBase |
-| CImplements | IBase |
-| CImplementsGeneric | IGenericBase |
-| CImplementsString | IGenericBase |
-| CStringSub | CGenericBase |
-| CSub | CBase |
-| IEmptySub | IEmpty |
-| IGenericSub | IGenericBase |
-| IMulti | IBase |
-| IMulti | IGenericBase |
-| IStringSub | IGenericBase |
-| ISub | IBase |
diff --git a/javascript/ql/test/library-tests/TypeScript/BaseTypes/BaseTypes.ql b/javascript/ql/test/library-tests/TypeScript/BaseTypes/BaseTypes.ql
deleted file mode 100644
index c54177d9c09..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/BaseTypes/BaseTypes.ql
+++ /dev/null
@@ -1,4 +0,0 @@
-import javascript
-
-from TypeName typename
-select typename.getName(), typename.getABaseTypeName().getName()
diff --git a/javascript/ql/test/library-tests/TypeScript/BaseTypes/SelfTypes.expected b/javascript/ql/test/library-tests/TypeScript/BaseTypes/SelfTypes.expected
deleted file mode 100644
index c82909543df..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/BaseTypes/SelfTypes.expected
+++ /dev/null
@@ -1,17 +0,0 @@
-| CBase | CBase |
-| CEverything | CEverything |
-| CGenericBase | CGenericBase |
-| CGenericSub | CGenericSub |
-| CImplements | CImplements |
-| CImplementsGeneric | CImplementsGeneric |
-| CImplementsString | CImplementsString |
-| CStringSub | CStringSub |
-| CSub | CSub |
-| IBase | IBase |
-| IEmpty | IEmpty |
-| IEmptySub | IEmptySub |
-| IGenericBase | IGenericBase |
-| IGenericSub | IGenericSub |
-| IMulti | IMulti |
-| IStringSub | IStringSub |
-| ISub | ISub |
diff --git a/javascript/ql/test/library-tests/TypeScript/BaseTypes/SelfTypes.ql b/javascript/ql/test/library-tests/TypeScript/BaseTypes/SelfTypes.ql
deleted file mode 100644
index 34a00e7d76a..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/BaseTypes/SelfTypes.ql
+++ /dev/null
@@ -1,4 +0,0 @@
-import javascript
-
-from TypeName tn
-select tn.getName(), tn.getType()
diff --git a/javascript/ql/test/library-tests/TypeScript/BaseTypes/tsconfig.json b/javascript/ql/test/library-tests/TypeScript/BaseTypes/tsconfig.json
deleted file mode 100644
index 0967ef424bc..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/BaseTypes/tsconfig.json
+++ /dev/null
@@ -1 +0,0 @@
-{}
diff --git a/javascript/ql/test/library-tests/TypeScript/BaseTypes/tst.ts b/javascript/ql/test/library-tests/TypeScript/BaseTypes/tst.ts
deleted file mode 100644
index b2b4a60b4ef..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/BaseTypes/tst.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-interface IBase {
- x: string;
-}
-interface ISub extends IBase {
- y: string;
-}
-
-interface IGenericBase {
- w: T;
-}
-interface IStringSub extends IGenericBase {}
-interface IGenericSub extends IGenericBase {}
-
-class CBase {}
-class CSub extends CBase {}
-
-class CGenericBase {}
-class CStringSub extends CGenericBase {}
-class CGenericSub extends CGenericBase {}
-
-interface IMulti extends IBase, IGenericBase {}
-
-abstract class CImplements implements IBase {
- x: string;
-}
-abstract class CImplementsString implements IGenericBase {
- w: string;
-}
-abstract class CImplementsGeneric implements IGenericBase {
- w: Q;
-}
-
-abstract class CEverything extends CGenericBase implements IGenericSub, IBase {
- x: string;
- w: T;
-}
-
-interface IEmpty {}
-interface IEmptySub extends IEmpty {}
diff --git a/javascript/ql/test/library-tests/TypeScript/BigInts/tests.expected b/javascript/ql/test/library-tests/TypeScript/BigInts/tests.expected
index dcbb70d415a..3891c6c9f12 100644
--- a/javascript/ql/test/library-tests/TypeScript/BigInts/tests.expected
+++ b/javascript/ql/test/library-tests/TypeScript/BigInts/tests.expected
@@ -4,14 +4,7 @@ exprFloatValue
| tst.ts:3:25:3:56 | 1000000 ... 000000n | 1.0E30 |
exprIntValue
| tst.ts:1:25:1:28 | 100n | 100 |
-exprWithBigIntType
-| tst.ts:1:5:1:11 | hundred |
-| tst.ts:2:5:2:12 | bigValue |
-| tst.ts:3:5:3:20 | bigNegativeValue |
-| tst.ts:5:5:5:14 | bigintType |
literalTypeExprIntValue
| tst.ts:6:24:6:28 | 1000n | 1000 |
typeExpr
| tst.ts:5:24:5:29 | bigint |
-typeIntValue
-| 1000n | 1000 |
diff --git a/javascript/ql/test/library-tests/TypeScript/BigInts/tests.ql b/javascript/ql/test/library-tests/TypeScript/BigInts/tests.ql
index 233d75f428d..120ff4434a4 100644
--- a/javascript/ql/test/library-tests/TypeScript/BigInts/tests.ql
+++ b/javascript/ql/test/library-tests/TypeScript/BigInts/tests.ql
@@ -4,12 +4,8 @@ query predicate exprFloatValue(BigIntLiteral literal, float f) { f = literal.get
query predicate exprIntValue(BigIntLiteral literal, int i) { i = literal.getIntValue() }
-query predicate exprWithBigIntType(Expr e) { e.getType() instanceof BigIntType }
-
query predicate literalTypeExprIntValue(BigIntLiteralTypeExpr type, int val) {
val = type.getIntValue()
}
query predicate typeExpr(TypeExpr type) { type.isBigInt() }
-
-query predicate typeIntValue(BigIntLiteralType type, int i) { type.getIntValue() = i }
diff --git a/javascript/ql/test/library-tests/TypeScript/CallResolution/CallResolution.expected b/javascript/ql/test/library-tests/TypeScript/CallResolution/CallResolution.expected
deleted file mode 100644
index a942a68076b..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/CallResolution/CallResolution.expected
+++ /dev/null
@@ -1,24 +0,0 @@
-| tst.ts:52:3:52:23 | obj.sim ... od(str) | (x: string): number | 0 |
-| tst.ts:53:3:53:24 | obj.gen ... od(str) | (x: string): string | 0 |
-| tst.ts:54:3:54:24 | obj.gen ... od(num) | (x: number): number | 0 |
-| tst.ts:55:3:55:27 | obj.ove ... od(num) | (x: number): number | 0 |
-| tst.ts:56:3:56:27 | obj.ove ... od(str) | (x: string): string | 1 |
-| tst.ts:57:3:57:26 | obj.ove ... hod([]) | (x: any): any | 2 |
-| tst.ts:58:3:58:36 | obj.gen ... ([num]) | (x: number[]): number | 0 |
-| tst.ts:59:3:59:39 | obj.gen ... : str}) | (x: Box): string | 1 |
-| tst.ts:60:3:60:34 | obj.gen ... od(num) | (x: any): any | 2 |
-| tst.ts:64:3:64:23 | obj.sim ... od(str) | (x: string): number | 0 |
-| tst.ts:65:3:65:24 | obj.gen ... od(str) | (x: string): string | 0 |
-| tst.ts:66:3:66:24 | obj.gen ... od(num) | (x: number): number | 0 |
-| tst.ts:67:3:67:27 | obj.ove ... od(num) | (x: number): number | 0 |
-| tst.ts:68:3:68:27 | obj.ove ... od(str) | (x: string): string | 1 |
-| tst.ts:69:3:69:36 | obj.gen ... ([num]) | (x: number[]): number | 0 |
-| tst.ts:70:3:70:39 | obj.gen ... : str}) | (x: Box): string | 1 |
-| tst.ts:74:3:74:28 | new Sim ... or(str) | new (x: string): SimpleConstructor | 0 |
-| tst.ts:75:3:75:29 | new Gen ... or(str) | new (x: string): GenericConstructor | 0 |
-| tst.ts:76:3:76:29 | new Gen ... or(num) | new (x: number): GenericConstructor | 0 |
-| tst.ts:77:3:77:37 | new Ove ... m, num) | new (x: number, y: number): OverloadedConstructor | 0 |
-| tst.ts:78:3:78:37 | new Ove ... r, str) | new (x: string, y: string): OverloadedConstructor | 1 |
-| tst.ts:79:3:79:48 | new Gen ... [str]) | new (x: string[], y: string[]): GenericOverloadedConstructor | 0 |
-| tst.ts:80:3:80:54 | new Gen ... : num}) | new (x: Box, y: Box): GenericOverloadedConstructor): T; |
-| tst.ts:58:3:58:36 | obj.gen ... ([num]) | TestInterface.genericOverloadedMethod in global scope | generic ... []): T; |
-| tst.ts:59:3:59:39 | obj.gen ... : str}) | TestInterface.genericOverloadedMethod in global scope | generic ... ): any; |
-| tst.ts:59:3:59:39 | obj.gen ... : str}) | TestInterface.genericOverloadedMethod in global scope | generic ... T>): T; |
-| tst.ts:59:3:59:39 | obj.gen ... : str}) | TestInterface.genericOverloadedMethod in global scope | generic ... []): T; |
-| tst.ts:60:3:60:34 | obj.gen ... od(num) | TestInterface.genericOverloadedMethod in global scope | generic ... ): any; |
-| tst.ts:60:3:60:34 | obj.gen ... od(num) | TestInterface.genericOverloadedMethod in global scope | generic ... T>): T; |
-| tst.ts:60:3:60:34 | obj.gen ... od(num) | TestInterface.genericOverloadedMethod in global scope | generic ... []): T; |
-| tst.ts:64:3:64:23 | obj.sim ... od(str) | TestClass.simpleMethod in global scope | simpleM ... ength } |
-| tst.ts:65:3:65:24 | obj.gen ... od(str) | TestClass.genericMethod in global scope | generic ... rn x; } |
-| tst.ts:66:3:66:24 | obj.gen ... od(num) | TestClass.genericMethod in global scope | generic ... rn x; } |
-| tst.ts:67:3:67:27 | obj.ove ... od(num) | TestClass.overloadedMethod in global scope | overloa ... number; |
-| tst.ts:67:3:67:27 | obj.ove ... od(num) | TestClass.overloadedMethod in global scope | overloa ... rn x; } |
-| tst.ts:67:3:67:27 | obj.ove ... od(num) | TestClass.overloadedMethod in global scope | overloa ... string; |
-| tst.ts:68:3:68:27 | obj.ove ... od(str) | TestClass.overloadedMethod in global scope | overloa ... number; |
-| tst.ts:68:3:68:27 | obj.ove ... od(str) | TestClass.overloadedMethod in global scope | overloa ... rn x; } |
-| tst.ts:68:3:68:27 | obj.ove ... od(str) | TestClass.overloadedMethod in global scope | overloa ... string; |
-| tst.ts:69:3:69:36 | obj.gen ... ([num]) | TestClass.genericOverloadedMethod in global scope | generic ... T>): T; |
-| tst.ts:69:3:69:36 | obj.gen ... ([num]) | TestClass.genericOverloadedMethod in global scope | generic ... []): T; |
-| tst.ts:69:3:69:36 | obj.gen ... ([num]) | TestClass.genericOverloadedMethod in global scope | generic ... null; } |
-| tst.ts:70:3:70:39 | obj.gen ... : str}) | TestClass.genericOverloadedMethod in global scope | generic ... T>): T; |
-| tst.ts:70:3:70:39 | obj.gen ... : str}) | TestClass.genericOverloadedMethod in global scope | generic ... []): T; |
-| tst.ts:70:3:70:39 | obj.gen ... : str}) | TestClass.genericOverloadedMethod in global scope | generic ... null; } |
diff --git a/javascript/ql/test/library-tests/TypeScript/CallResolution/CallTarget.ql b/javascript/ql/test/library-tests/TypeScript/CallResolution/CallTarget.ql
deleted file mode 100644
index 759c9d5e7c7..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/CallResolution/CallTarget.ql
+++ /dev/null
@@ -1,11 +0,0 @@
-import javascript
-
-string getTarget(InvokeExpr e) {
- result = e.getResolvedCallee().toString()
- or
- not exists(e.getResolvedCallee()) and
- result = "no concrete target"
-}
-
-from InvokeExpr invoke
-select invoke, invoke.getResolvedCalleeName(), getTarget(invoke)
diff --git a/javascript/ql/test/library-tests/TypeScript/CallResolution/tsconfig.json b/javascript/ql/test/library-tests/TypeScript/CallResolution/tsconfig.json
deleted file mode 100644
index 0967ef424bc..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/CallResolution/tsconfig.json
+++ /dev/null
@@ -1 +0,0 @@
-{}
diff --git a/javascript/ql/test/library-tests/TypeScript/CallResolution/tst.ts b/javascript/ql/test/library-tests/TypeScript/CallResolution/tst.ts
deleted file mode 100644
index 9f893a6f147..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/CallResolution/tst.ts
+++ /dev/null
@@ -1,85 +0,0 @@
-interface Box { x: T }
-
-interface TestInterface {
- simpleMethod(x: string): number;
-
- genericMethod(x: T): T;
-
- overloadedMethod(x: number): number;
- overloadedMethod(x: string): string;
- overloadedMethod(x: any): any;
-
- genericOverloadedMethod(x: T[]): T;
- genericOverloadedMethod(x: Box): T;
- genericOverloadedMethod(x: any): any;
-}
-
-class TestClass {
- simpleMethod(x: string): number { return x.length }
-
- genericMethod(x: T): T { return x; }
-
- overloadedMethod(x: number): number;
- overloadedMethod(x: string): string;
- overloadedMethod(x: any): any { return x; }
-
- genericOverloadedMethod(x: T[]): T;
- genericOverloadedMethod(x: Box): T;
- genericOverloadedMethod(x: any): any { return x.x || x[0] || null; }
-}
-
-class SimpleConstructor {
- constructor(x: string) {}
-}
-
-class GenericConstructor {
- constructor(x: T) {}
-}
-
-class OverloadedConstructor {
- constructor(x: number, y: number);
- constructor(x: string, y: string);
- constructor(x: any, y: any) {}
-}
-
-class GenericOverloadedConstructor {
- constructor(x: T[], y: T[]);
- constructor(x: Box, y: Box);
- constructor(x: any, y: any) {}
-}
-
-function useTestInterface(obj: TestInterface, str: string, num: number) {
- obj.simpleMethod(str);
- obj.genericMethod(str);
- obj.genericMethod(num);
- obj.overloadedMethod(num);
- obj.overloadedMethod(str);
- obj.overloadedMethod([]);
- obj.genericOverloadedMethod([num]);
- obj.genericOverloadedMethod({x: str});
- obj.genericOverloadedMethod(num);
-}
-
-function useTestClass(obj: TestClass, str: string, num: number) {
- obj.simpleMethod(str);
- obj.genericMethod(str);
- obj.genericMethod(num);
- obj.overloadedMethod(num);
- obj.overloadedMethod(str);
- obj.genericOverloadedMethod([num]);
- obj.genericOverloadedMethod({x: str});
-}
-
-function testConstructors(str: string, num: number) {
- new SimpleConstructor(str);
- new GenericConstructor(str);
- new GenericConstructor(num);
- new OverloadedConstructor(num, num);
- new OverloadedConstructor(str, str);
- new GenericOverloadedConstructor([str], [str]);
- new GenericOverloadedConstructor({x: num}, {x: num});
-}
-
-function testCallback(callback: (x: string) => U): U {
- return callback("str");
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/CallSignatureTypes/test.expected b/javascript/ql/test/library-tests/TypeScript/CallSignatureTypes/test.expected
deleted file mode 100644
index 2c6bf9153a8..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/CallSignatureTypes/test.expected
+++ /dev/null
@@ -1,131 +0,0 @@
-test_ExprSignature
-| tst.ts:2:4:2:4 | x | number |
-| tst.ts:6:4:6:4 | x | number |
-| tst.ts:7:4:7:4 | x | string |
-| tst.ts:8:4:8:4 | x | any |
-| tst.ts:12:8:12:8 | x | number |
-| tst.ts:16:8:16:8 | x | number |
-| tst.ts:17:8:17:8 | x | any |
-| tst.ts:21:3:21:28 | method( ... string; | (x: number): string |
-| tst.ts:21:10:21:10 | x | number |
-| tst.ts:23:3:23:38 | overloa ... number; | (x: any): any |
-| tst.ts:23:3:23:38 | overloa ... number; | (x: number): number |
-| tst.ts:23:3:23:38 | overloa ... number; | (x: string): string |
-| tst.ts:23:20:23:20 | x | number |
-| tst.ts:24:3:24:38 | overloa ... string; | (x: any): any |
-| tst.ts:24:3:24:38 | overloa ... string; | (x: number): number |
-| tst.ts:24:3:24:38 | overloa ... string; | (x: string): string |
-| tst.ts:24:20:24:20 | x | string |
-| tst.ts:25:3:25:32 | overloa ... ): any; | (x: any): any |
-| tst.ts:25:3:25:32 | overloa ... ): any; | (x: number): number |
-| tst.ts:25:3:25:32 | overloa ... ): any; | (x: string): string |
-| tst.ts:25:20:25:20 | x | any |
-| tst.ts:28:5:28:5 | m | Method |
-| tst.ts:29:1:29:1 | m | Method |
-| tst.ts:29:1:29:8 | m.method | (x: number): string |
-| tst.ts:29:1:29:12 | m.method(42) | string |
-| tst.ts:29:10:29:11 | 42 | 42 |
-| tst.ts:30:1:30:1 | m | Method |
-| tst.ts:30:1:30:18 | m.overloadedMethod | (x: any): any |
-| tst.ts:30:1:30:18 | m.overloadedMethod | (x: number): number |
-| tst.ts:30:1:30:18 | m.overloadedMethod | (x: string): string |
-| tst.ts:30:1:30:25 | m.overl ... ("foo") | string |
-| tst.ts:30:20:30:24 | "foo" | "foo" |
-| tst.ts:33:3:33:10 | callback | (x: number): string |
-| tst.ts:33:13:33:33 | (x: num ... string | (x: number): string |
-| tst.ts:33:14:33:14 | x | number |
-| tst.ts:37:3:37:18 | method(x: T): T; | (x: T): T |
-| tst.ts:37:10:37:10 | x | T |
-| tst.ts:40:10:40:12 | foo | (g: Generic): string |
-| tst.ts:40:14:40:14 | g | Generic |
-| tst.ts:41:10:41:10 | g | Generic |
-| tst.ts:41:10:41:17 | g.method | (x: string): string |
-| tst.ts:41:10:41:24 | g.method("foo") | string |
-| tst.ts:41:19:41:23 | "foo" | "foo" |
-| tst.ts:44:15:44:15 | C | C |
-| tst.ts:45:3:45:25 | constru ... tring); | any |
-| tst.ts:45:15:45:15 | x | string |
-| tst.ts:46:3:46:25 | constru ... umber); | any |
-| tst.ts:46:15:46:15 | x | number |
-| tst.ts:50:3:50:36 | method( ... ing[]); | (x: number, ...y: string[]): any |
-| tst.ts:50:10:50:10 | x | number |
-| tst.ts:50:24:50:24 | y | string[] |
-| tst.ts:51:4:51:4 | x | number |
-| tst.ts:51:18:51:18 | y | string[] |
-| tst.ts:52:7:52:7 | x | number |
-| tst.ts:52:21:52:21 | y | string[] |
-| tst.ts:54:3:54:34 | method2 ... ing[]); | (x: number, y: string[]): any |
-| tst.ts:54:11:54:11 | x | number |
-| tst.ts:54:22:54:22 | y | string[] |
-| tst.ts:55:3:55:32 | method3 ... tring); | (x: number, y: string): any |
-| tst.ts:55:11:55:11 | x | number |
-| tst.ts:55:22:55:22 | y | string |
-| tst.ts:59:3:59:25 | method( ... ing[]); | (...y: string[]): any |
-| tst.ts:59:13:59:13 | y | string[] |
-| tst.ts:60:7:60:7 | y | string[] |
-| tst.ts:61:10:61:10 | y | string[] |
-| tst.ts:63:3:63:23 | method2 ... ing[]); | (y: string[]): any |
-| tst.ts:63:11:63:11 | y | string[] |
-| tst.ts:64:3:64:21 | method3(y: string); | (y: string): any |
-| tst.ts:64:11:64:11 | y | string |
-test_TypeReferenceSig
-| Callable | function | 0 | (x: number): string |
-| Newable | constructor | 0 | new (x: number): any |
-| OnlyRestParams | constructor | 0 | new (...y: string[]): any |
-| OnlyRestParams | function | 0 | (...y: string[]): any |
-| OverloadedCallable | function | 0 | (x: number): number |
-| OverloadedCallable | function | 1 | (x: string): string |
-| OverloadedCallable | function | 2 | (x: any): any |
-| OverloadedNewable | constructor | 0 | new (x: number): OverloadedNewable |
-| OverloadedNewable | constructor | 1 | new (x: any): any |
-| WithRestParams | constructor | 0 | new (x: number, ...y: string[]): any |
-| WithRestParams | function | 0 | (x: number, ...y: string[]): any |
-test_FunctionCallSig
-| tst.ts:2:3:2:22 | (x: number): string; | (x: number): string |
-| tst.ts:6:3:6:22 | (x: number): number; | (x: number): number |
-| tst.ts:7:3:7:22 | (x: string): string; | (x: string): string |
-| tst.ts:8:3:8:16 | (x: any): any; | (x: any): any |
-| tst.ts:12:3:12:23 | new (x: ... ): any; | new (x: number): any |
-| tst.ts:16:3:16:37 | new (x: ... ewable; | new (x: number): OverloadedNewable |
-| tst.ts:17:3:17:20 | new (x: any): any; | new (x: any): any |
-| tst.ts:21:3:21:28 | method( ... string; | (x: number): string |
-| tst.ts:23:3:23:38 | overloa ... number; | (x: number): number |
-| tst.ts:24:3:24:38 | overloa ... string; | (x: string): string |
-| tst.ts:25:3:25:32 | overloa ... ): any; | (x: any): any |
-| tst.ts:33:13:33:33 | (x: num ... string | (x: number): string |
-| tst.ts:37:3:37:18 | method(x: T): T; | (x: T): T |
-| tst.ts:40:1:42:1 | functio ... oo");\\n} | (g: Generic): string |
-| tst.ts:45:3:45:25 | constru ... tring); | new (x: string): C |
-| tst.ts:46:3:46:25 | constru ... umber); | new (x: number): C |
-| tst.ts:50:3:50:36 | method( ... ing[]); | (x: number, ...y: string[]): any |
-| tst.ts:51:3:51:30 | (x: num ... ing[]); | (x: number, ...y: string[]): any |
-| tst.ts:52:3:52:33 | new(x: ... ing[]); | new (x: number, ...y: string[]): any |
-| tst.ts:54:3:54:34 | method2 ... ing[]); | (x: number, y: string[]): any |
-| tst.ts:55:3:55:32 | method3 ... tring); | (x: number, y: string): any |
-| tst.ts:59:3:59:25 | method( ... ing[]); | (...y: string[]): any |
-| tst.ts:60:3:60:19 | (...y: string[]); | (...y: string[]): any |
-| tst.ts:61:3:61:22 | new(...y: string[]); | new (...y: string[]): any |
-| tst.ts:63:3:63:23 | method2 ... ing[]); | (y: string[]): any |
-| tst.ts:64:3:64:21 | method3(y: string); | (y: string): any |
-test_getRestParameterType
-| (...y: string[]): any | string |
-| (x: number, ...y: string[]): any | string |
-| new (...y: string[]): any | string |
-| new (x: number, ...y: string[]): any | string |
-test_getRestParameterArray
-| (...y: string[]): any | string[] |
-| (x: number, ...y: string[]): any | string[] |
-| new (...y: string[]): any | string[] |
-| new (x: number, ...y: string[]): any | string[] |
-test_RestSig_getParameter
-| (...y: string[]): any | 0 | y | string |
-| (x: number, ...y: string[]): any | 0 | x | number |
-| (x: number, ...y: string[]): any | 1 | y | string |
-| new (...y: string[]): any | 0 | y | string |
-| new (x: number, ...y: string[]): any | 0 | x | number |
-| new (x: number, ...y: string[]): any | 1 | y | string |
-test_RestSig_numRequiredParams
-| (...y: string[]): any | 0 |
-| (x: number, ...y: string[]): any | 1 |
-| new (...y: string[]): any | 0 |
-| new (x: number, ...y: string[]): any | 1 |
diff --git a/javascript/ql/test/library-tests/TypeScript/CallSignatureTypes/test.ql b/javascript/ql/test/library-tests/TypeScript/CallSignatureTypes/test.ql
deleted file mode 100644
index 03cc288f054..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/CallSignatureTypes/test.ql
+++ /dev/null
@@ -1,41 +0,0 @@
-import javascript
-
-string getASignatureOrElseType(Type t) {
- result = t.getASignature(_).toString()
- or
- not exists(t.getASignature(_)) and
- result = t.toString()
-}
-
-query predicate test_ExprSignature(Expr expr, string type) {
- not exists(MethodDeclaration decl | decl.getNameExpr() = expr) and
- not exists(DotExpr dot | expr = dot.getPropertyNameExpr()) and
- type = getASignatureOrElseType(expr.getType())
-}
-
-query predicate test_TypeReferenceSig(
- TypeReference type, SignatureKind kind, int n, CallSignatureType sig
-) {
- sig = type.getSignature(kind, n)
-}
-
-query predicate test_FunctionCallSig(Function f, CallSignatureType sig) {
- sig = f.getCallSignature()
-}
-
-query Type test_getRestParameterType(CallSignatureType sig) { result = sig.getRestParameterType() }
-
-query Type test_getRestParameterArray(CallSignatureType sig) {
- result = sig.getRestParameterArrayType()
-}
-
-query predicate test_RestSig_getParameter(CallSignatureType sig, int n, string name, Type type) {
- sig.hasRestParameter() and
- name = sig.getParameterName(n) and
- type = sig.getParameter(n)
-}
-
-query int test_RestSig_numRequiredParams(CallSignatureType sig) {
- sig.hasRestParameter() and
- result = sig.getNumRequiredParameter()
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/CallSignatureTypes/tsconfig.json b/javascript/ql/test/library-tests/TypeScript/CallSignatureTypes/tsconfig.json
deleted file mode 100644
index 0967ef424bc..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/CallSignatureTypes/tsconfig.json
+++ /dev/null
@@ -1 +0,0 @@
-{}
diff --git a/javascript/ql/test/library-tests/TypeScript/CallSignatureTypes/tst.ts b/javascript/ql/test/library-tests/TypeScript/CallSignatureTypes/tst.ts
deleted file mode 100644
index ed0ab3bcfd6..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/CallSignatureTypes/tst.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-interface Callable {
- (x: number): string;
-}
-
-interface OverloadedCallable {
- (x: number): number;
- (x: string): string;
- (x: any): any;
-}
-
-interface Newable {
- new (x: number): any;
-}
-
-interface OverloadedNewable {
- new (x: number): OverloadedNewable;
- new (x: any): any;
-}
-
-interface Method {
- method(x: number): string;
-
- overloadedMethod(x: number): number;
- overloadedMethod(x: string): string;
- overloadedMethod(x: any): any;
-}
-
-let m: Method;
-m.method(42);
-m.overloadedMethod("foo");
-
-interface FunctionTypeField {
- callback: (x: number) => string;
-}
-
-interface Generic {
- method(x: T): T;
-}
-
-function foo(g: Generic) {
- return g.method("foo");
-}
-
-declare class C {
- constructor(x: string);
- constructor(x: number);
-}
-
-interface WithRestParams {
- method(x: number, ...y: string[]);
- (x: number, ...y: string[]);
- new(x: number, ...y: string[]);
-
- method2(x: number, y: string[]);
- method3(x: number, y: string);
-}
-
-interface OnlyRestParams {
- method(...y: string[]);
- (...y: string[]);
- new(...y: string[]);
-
- method2(y: string[]);
- method3(y: string);
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/DeclarationFiles/TypeResolution.expected b/javascript/ql/test/library-tests/TypeScript/DeclarationFiles/TypeResolution.expected
deleted file mode 100644
index 470c051d228..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/DeclarationFiles/TypeResolution.expected
+++ /dev/null
@@ -1,8 +0,0 @@
-| client1.ts:4:9:4:19 | F.Component | Component in module 'framework1' |
-| client1.ts:5:9:5:29 | Util.De ... mponent | Util.DefaultComponent in global scope |
-| client2.ts:4:9:4:19 | F.Component | Component in module 'framework2' |
-| client2.ts:5:9:5:30 | Util2.D ... mponent | Util2.DefaultComponent in global scope |
-| client2_lazy.ts:4:9:4:19 | F.Component | Component in module 'framework2' |
-| client2_lazy.ts:5:9:5:30 | Util2.D ... mponent | Util2.DefaultComponent in global scope |
-| declare-module-client2.ts:5:8:5:8 | C | C in module 'foo' |
-| declare-module-client.ts:5:8:5:8 | C | C in module 'foo' |
diff --git a/javascript/ql/test/library-tests/TypeScript/DeclarationFiles/TypeResolution.ql b/javascript/ql/test/library-tests/TypeScript/DeclarationFiles/TypeResolution.ql
deleted file mode 100644
index dbaf61b998f..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/DeclarationFiles/TypeResolution.ql
+++ /dev/null
@@ -1,4 +0,0 @@
-import javascript
-
-from TypeAccess access
-select access, access.getTypeName()
diff --git a/javascript/ql/test/library-tests/TypeScript/EmbeddedInScript/Test.expected b/javascript/ql/test/library-tests/TypeScript/EmbeddedInScript/Test.expected
index 2bb7faf59eb..c2ef2098362 100644
--- a/javascript/ql/test/library-tests/TypeScript/EmbeddedInScript/Test.expected
+++ b/javascript/ql/test/library-tests/TypeScript/EmbeddedInScript/Test.expected
@@ -1,34 +1,6 @@
classDeclaration
| test.vue:3:18:5:3 | class M ... er;\\n } |
| test_tsx.vue:3:18:5:3 | class M ... er;\\n } |
-exprType
-| htmlfile.html:4:22:4:24 | foo | () => void |
-| htmlfile.html:4:33:4:41 | "./other" | any |
-| htmlfile.html:5:17:5:22 | result | number[] |
-| htmlfile.html:5:26:5:28 | foo | () => void |
-| htmlfile.html:5:26:5:30 | foo() | void |
-| htmlfile.html:5:26:5:42 | foo() as number[] | number[] |
-| other.ts:1:8:1:16 | Component | typeof default in test.vue |
-| other.ts:1:23:1:34 | "./test.vue" | any |
-| other.ts:2:8:2:19 | ComponentTsx | typeof default in test_tsx.vue |
-| other.ts:2:26:2:41 | "./test_tsx.vue" | any |
-| other.ts:4:1:4:15 | new Component() | MyComponent |
-| other.ts:4:5:4:13 | Component | typeof default in test.vue |
-| other.ts:5:1:5:18 | new ComponentTsx() | MyComponentTsx |
-| other.ts:5:5:5:16 | ComponentTsx | typeof default in test_tsx.vue |
-| other.ts:7:17:7:19 | foo | () => void |
-| test.vue:2:15:2:19 | other | typeof other.ts |
-| test.vue:2:26:2:34 | "./other" | any |
-| test.vue:3:24:3:34 | MyComponent | MyComponent |
-| test.vue:4:7:4:7 | x | number |
-| test_tsx.vue:2:15:2:19 | other | typeof other.ts |
-| test_tsx.vue:2:26:2:34 | "./other" | any |
-| test_tsx.vue:3:24:3:37 | MyComponentTsx | MyComponentTsx |
-| test_tsx.vue:4:7:4:7 | x | number |
-symbols
-| other.ts:1:1:8:0 | | other.ts |
-| test.vue:2:3:6:0 | | test.vue |
-| test_tsx.vue:2:3:6:0 | | test_tsx.vue |
importTarget
| htmlfile.html:4:13:4:42 | import ... other"; | other.ts:1:1:8:0 | |
| other.ts:1:1:1:35 | import ... t.vue"; | test.vue:2:3:6:0 | |
diff --git a/javascript/ql/test/library-tests/TypeScript/EmbeddedInScript/Test.ql b/javascript/ql/test/library-tests/TypeScript/EmbeddedInScript/Test.ql
index 43a718bf77b..e333dc900d9 100644
--- a/javascript/ql/test/library-tests/TypeScript/EmbeddedInScript/Test.ql
+++ b/javascript/ql/test/library-tests/TypeScript/EmbeddedInScript/Test.ql
@@ -2,8 +2,4 @@ import javascript
query ClassDefinition classDeclaration() { any() }
-query Type exprType(Expr e) { result = e.getType() }
-
-query predicate symbols(Module mod, CanonicalName name) { ast_node_symbol(mod, name) }
-
query predicate importTarget(Import imprt, Module mod) { imprt.getImportedModule() = mod }
diff --git a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/Types.expected b/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/Types.expected
deleted file mode 100644
index b769d79a261..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/Types.expected
+++ /dev/null
@@ -1,77 +0,0 @@
-| After |
-| AfterX |
-| Before |
-| BeforeX |
-| Box> |
-| Box |
-| Box |
-| Box |
-| Box |
-| C |
-| C |
-| Expand |
-| Expand |
-| ExpandUsingObjectLiteral |
-| ExpandUsingObjectLiteral |
-| Expansive |
-| Expansive |
-| Expansive |
-| Expansive |
-| Expansive |
-| Expansive |
-| ExpansiveA |
-| ExpansiveA |
-| ExpansiveA |
-| ExpansiveA |
-| ExpansiveB |
-| ExpansiveB |
-| ExpansiveB |
-| ExpansiveB |
-| ExpansiveB |
-| ExpansiveB |
-| ExpansiveByInference |
-| ExpansiveByInference |
-| ExpansiveC |
-| ExpansiveC |
-| ExpansiveC |
-| ExpansiveC |
-| ExpansiveC |
-| ExpansiveC |
-| ExpansiveConstructSignature |
-| ExpansiveConstructSignature |
-| ExpansiveD |
-| ExpansiveD |
-| ExpansiveD |
-| ExpansiveD |
-| ExpansiveFunctionType |
-| ExpansiveFunctionType |
-| ExpansiveMethod |
-| ExpansiveMethod |
-| ExpansiveParameter |
-| ExpansiveParameter |
-| ExpansiveSignature |
-| ExpansiveSignature |
-| ExpansiveSignatureTypeBound |
-| ExpansiveSignatureTypeBound |
-| ExpansiveX |
-| ExpansiveX |
-| NonExpansive> |
-| NonExpansive |
-| T[] |
-| T[] |
-| T[] |
-| T[] |
-| T[] |
-| T[] |
-| T[] |
-| T[] |
-| T[] |
-| T[] |
-| T[] |
-| T[] |
-| T[] |
-| T[] |
-| T[] |
-| T[] |
-| T[] |
-| T[] |
diff --git a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/Types.ql b/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/Types.ql
deleted file mode 100644
index 6890e293776..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/Types.ql
+++ /dev/null
@@ -1,4 +0,0 @@
-import javascript
-
-from TypeReference type
-select type
diff --git a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/dummy.ts b/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/dummy.ts
deleted file mode 100644
index 91779e66b25..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/dummy.ts
+++ /dev/null
@@ -1 +0,0 @@
-export let x = 1;
\ No newline at end of file
diff --git a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/expansive_by_inference.ts b/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/expansive_by_inference.ts
deleted file mode 100644
index 62e41ce4c67..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/expansive_by_inference.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import * as dummy from "./dummy";
-
-class ExpansiveByInference {
- x: T;
- y = new ExpansiveByInference([this.x]); // Inferred to be `ExpansiveByInference`
-
- constructor(arg: T) {}
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/expansive_class.ts b/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/expansive_class.ts
deleted file mode 100644
index 354a9f9230c..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/expansive_class.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import * as dummy from "./dummy";
-
-class C {
- x: C;
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/expansive_object_literal.ts b/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/expansive_object_literal.ts
deleted file mode 100644
index 9225f1e1bbf..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/expansive_object_literal.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import * as dummy from "./dummy";
-
-interface ExpandUsingObjectLiteral {
- x: {
- foo: ExpandUsingObjectLiteral
- }
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/expansive_signature.ts b/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/expansive_signature.ts
deleted file mode 100644
index 6bdfd8e1f2a..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/expansive_signature.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import * as dummy from "./dummy";
-
-interface ExpansiveSignature {
- x: { (): ExpansiveSignature; }
-}
-
-interface ExpansiveParameter {
- x: { (param: ExpansiveParameter): void; }
-}
-
-interface ExpansiveConstructSignature {
- x: { new(): ExpansiveConstructSignature; }
-}
-
-interface ExpansiveMethod {
- method(): ExpansiveMethod;
-}
-
-interface ExpansiveFunctionType {
- x: () => ExpansiveFunctionType;
-}
-
-interface ExpansiveSignatureTypeBound {
- foo : { >(x: G): G };
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/leading_into_expansion.ts b/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/leading_into_expansion.ts
deleted file mode 100644
index 0df863991db..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/leading_into_expansion.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import * as dummy from "./dummy";
-
-interface Before {
- x: Expansive;
-}
-
-interface Expansive {
- x: Expansive;
-}
-
-interface After {
- x: Expansive;
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/mutual.ts b/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/mutual.ts
deleted file mode 100644
index 05682c45928..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/mutual.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-import * as dummy from "./dummy";
-
-interface ExpansiveA {
- x: ExpansiveB;
-}
-
-interface ExpansiveB {
- x: ExpansiveA;
-}
-
-
-interface ExpansiveC {
- x: ExpansiveD;
-}
-interface ExpansiveD {
- x: ExpansiveC;
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/mutual_multigraph.ts b/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/mutual_multigraph.ts
deleted file mode 100644
index 22a2917fe41..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/mutual_multigraph.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import * as dummy from "./dummy";
-
-// The expansive edge may be preceded by non-expansive edges.
-
-interface ExpansiveA {
- a: ExpansiveB;
- b: ExpansiveB;
- x: ExpansiveB;
-}
-
-interface ExpansiveB {
- x: ExpansiveA;
-}
-
-
-interface ExpansiveC {
- x: ExpansiveD;
-}
-
-interface ExpansiveD {
- a: ExpansiveC;
- b: ExpansiveC;
- x: ExpansiveC;
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/shared_non_expansive.ts b/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/shared_non_expansive.ts
deleted file mode 100644
index 86dab87ad90..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/shared_non_expansive.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import * as dummy from "./dummy";
-
-// Box is not expansive by itself but expansions may go "through" it.
-interface Box {
- x: S;
-}
-
-// A too simple algorithm might classify this as expansive.
-interface NonExpansive {
- x: NonExpansive>;
- y: Box;
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/simple.ts b/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/simple.ts
deleted file mode 100644
index 8421124d7b8..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/simple.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import * as dummy from "./dummy";
-
-interface Expansive {
- x: Expansive;
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/through_non_expansive.ts b/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/through_non_expansive.ts
deleted file mode 100644
index 8724e9fd6c9..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/through_non_expansive.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import * as dummy from "./dummy";
-
-interface Expand {
- x: Box>
-}
-
-// Box is not expansive by itself but expansions may go "through" it.
-interface Box {
- x: S;
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/tsconfig.json b/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/tsconfig.json
deleted file mode 100644
index 0967ef424bc..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/tsconfig.json
+++ /dev/null
@@ -1 +0,0 @@
-{}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/used_from_expansion.ts b/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/used_from_expansion.ts
deleted file mode 100644
index 8ab40e5944a..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExpansiveTypes/used_from_expansion.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import * as dummy from "./dummy";
-
-interface BeforeX {
- x: number;
-}
-
-interface ExpansiveX {
- a: BeforeX;
- x: ExpansiveX;
- b: BeforeX;
-}
-
-interface AfterX {
- x: string;
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/BaseTypes.expected b/javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/BaseTypes.expected
deleted file mode 100644
index 48d4d2cf1d1..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/BaseTypes.expected
+++ /dev/null
@@ -1,3 +0,0 @@
-| B in module 'mylib' | A in module 'mylib' |
-| C in module 'mylib' | B in module 'mylib' |
-| D in module 'mylib' | C in module 'mylib' |
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/BaseTypes.ql b/javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/BaseTypes.ql
deleted file mode 100644
index b6595b03cba..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/BaseTypes.ql
+++ /dev/null
@@ -1,5 +0,0 @@
-import javascript
-
-from TypeName tn
-where tn.hasQualifiedName("mylib", _)
-select tn, tn.getABaseTypeName()
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/node_modules/@types/mylib/index.d.ts b/javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/node_modules/@types/mylib/index.d.ts
deleted file mode 100644
index 62cf0bacbf3..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/node_modules/@types/mylib/index.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export interface A {}
-export interface B extends A {}
-export interface C extends B {}
-export interface D extends C {}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/options b/javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/options
deleted file mode 100644
index e59bfd7d72e..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/options
+++ /dev/null
@@ -1 +0,0 @@
-semmle-extractor-options:--exclude node_modules/**
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/tsconfig.json b/javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/tsconfig.json
deleted file mode 100644
index c4df0713286..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/tsconfig.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "compilerOptions": {
- "baseUrl": "./"
- }
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/tst.ts b/javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/tst.ts
deleted file mode 100644
index 698f658d106..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalBaseTypes/tst.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { D } from "mylib";
-
-export var foo: D = null;
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/augmentation.ts b/javascript/ql/test/library-tests/TypeScript/ExternalTypes/augmentation.ts
deleted file mode 100644
index 36ece00b15d..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/augmentation.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { ExternalType1, Augmentation } from "esmodule";
-
-declare module "esmodule" {
- export interface Augmentation {
- x: ExternalType1;
- }
-}
-
-let x: Augmentation;
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_esmodule.ts b/javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_esmodule.ts
deleted file mode 100644
index c90291d0a0b..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_esmodule.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { ExternalType1, externalSymbol } from "esmodule";
-
-function f(arg: ExternalType1) {
- let y = arg.x; // y should be ExternalType2
-}
-
-let foo = 5;
-
-let bar: { x: number };
-
-interface InternalType {
- x: number;
- [externalSymbol]: number;
-}
-let symb = externalSymbol;
-
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_esmodule_extra.ts b/javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_esmodule_extra.ts
deleted file mode 100644
index 8fda57d2d78..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_esmodule_extra.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { OtherClass } from "esmodule/otherfile";
-import { UtilClass } from "esmodule/util";
-import { UtilExtraClass } from "esmodule/util/extra";
-
-let c1 = new OtherClass();
-let c2 = new UtilClass();
-let c3 = new UtilExtraClass();
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_legacy_global.ts b/javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_legacy_global.ts
deleted file mode 100644
index ee07ed41dc5..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_legacy_global.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-///
-
-let d = new LegacyGlobals.LegacySubclass();
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_legacy_module.ts b/javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_legacy_module.ts
deleted file mode 100644
index f0f45868d66..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_legacy_module.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { LegacyClass } from "legacy";
-
-let c: LegacyClass;
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_modern_global.ts b/javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_modern_global.ts
deleted file mode 100644
index b849a9b3b45..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_modern_global.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-///
-
-let d = new ModernGlobals.ModernSubclass();
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_modern_module.ts b/javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_modern_module.ts
deleted file mode 100644
index a79aded7060..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/client_modern_module.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import { ModernClass } from "modern";
-
-let c: ModernClass;
\ No newline at end of file
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/esmodule/index.d.ts b/javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/esmodule/index.d.ts
deleted file mode 100644
index 577a29e73b7..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/esmodule/index.d.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-export interface ExternalType1 {
- x: ExternalType2;
-}
-
-export interface ExternalType2 {
- x: number;
- y: number;
-}
-
-export const externalSymbol: unique symbol;
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/esmodule/otherfile.d.ts b/javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/esmodule/otherfile.d.ts
deleted file mode 100644
index 75147c48c6c..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/esmodule/otherfile.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export declare class OtherClass {}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/esmodule/util/extra.d.ts b/javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/esmodule/util/extra.d.ts
deleted file mode 100644
index 358c567c5f5..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/esmodule/util/extra.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export declare class UtilExtraClass {}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/esmodule/util/index.d.ts b/javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/esmodule/util/index.d.ts
deleted file mode 100644
index 90c9487a34b..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/esmodule/util/index.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export declare class UtilClass {}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/legacy/index.d.ts b/javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/legacy/index.d.ts
deleted file mode 100644
index f9017036134..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/legacy/index.d.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-declare namespace __Legacy {
- export class LegacyClass {}
-}
-
-declare module "legacy" {
- export = __Legacy;
-}
-
-declare namespace LegacyGlobals {
- import Legacy = __Legacy;
-
- class LegacySubclass extends Legacy.LegacyClass {}
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/modern/index.d.ts b/javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/modern/index.d.ts
deleted file mode 100644
index f02e5b7601c..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/node_modules/@types/modern/index.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export = Modern;
-export as namespace Modern;
-
-declare namespace Modern {
- class ModernClass {}
-}
-
-declare global {
- namespace ModernGlobals {
- class ModernSubclass extends Modern.ModernClass {}
- }
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/options b/javascript/ql/test/library-tests/TypeScript/ExternalTypes/options
deleted file mode 100644
index e59bfd7d72e..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/options
+++ /dev/null
@@ -1 +0,0 @@
-semmle-extractor-options:--exclude node_modules/**
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/tests.expected b/javascript/ql/test/library-tests/TypeScript/ExternalTypes/tests.expected
deleted file mode 100644
index 26ee4c9b67c..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/tests.expected
+++ /dev/null
@@ -1,28 +0,0 @@
-globalQualifiedNames
-| LegacyClass | __Legacy.LegacyClass |
-| LegacySubclass | LegacyGlobals.LegacySubclass |
-| ModernClass | Modern.ModernClass |
-| ModernSubclass | ModernGlobals.ModernSubclass |
-moduleQualifiedName
-| Augmentation | esmodule | Augmentation |
-| ExternalType1 | esmodule | ExternalType1 |
-| ExternalType2 | esmodule | ExternalType2 |
-| LegacyClass | legacy | LegacyClass |
-| ModernClass | modern | ModernClass |
-| OtherClass | esmodule/otherfile | OtherClass |
-| UtilClass | esmodule/util | UtilClass |
-| UtilExtraClass | esmodule/util/extra | UtilExtraClass |
-types
-| Augmentation | defined in augmentation.ts |
-| ExternalType1 | has no definition |
-| ExternalType2 | has no definition |
-| InternalType | defined in client_esmodule.ts |
-| LegacyClass | has no definition |
-| LegacySubclass | has no definition |
-| ModernClass | has no definition |
-| ModernSubclass | has no definition |
-| OtherClass | has no definition |
-| UtilClass | has no definition |
-| UtilExtraClass | has no definition |
-uniqueSymbols
-| typeof externalSymbol | esmodule | externalSymbol |
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/tests.ql b/javascript/ql/test/library-tests/TypeScript/ExternalTypes/tests.ql
deleted file mode 100644
index aedebb37bc9..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/tests.ql
+++ /dev/null
@@ -1,26 +0,0 @@
-import javascript
-
-query predicate globalQualifiedNames(TypeReference type, string globalName) {
- type.hasQualifiedName(globalName) and
- not type.hasTypeArguments()
-}
-
-query predicate moduleQualifiedName(TypeReference type, string moduleName, string exportedName) {
- type.hasQualifiedName(moduleName, exportedName) and
- not type.hasTypeArguments()
-}
-
-string getDefinition(TypeReference ref) {
- if exists(ref.getADefinition())
- then result = "defined in " + ref.getADefinition().getFile().getBaseName()
- else result = "has no definition"
-}
-
-query predicate types(TypeReference type, string def) {
- not type.hasTypeArguments() and
- def = getDefinition(type)
-}
-
-query predicate uniqueSymbols(UniqueSymbolType symbol, string moduleName, string exportedName) {
- symbol.hasQualifiedName(moduleName, exportedName)
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/tsconfig.json b/javascript/ql/test/library-tests/TypeScript/ExternalTypes/tsconfig.json
deleted file mode 100644
index c4df0713286..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ExternalTypes/tsconfig.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "compilerOptions": {
- "baseUrl": "./"
- }
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/HasUnderlyingType.expected b/javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/HasUnderlyingType.expected
deleted file mode 100644
index 91eb164f394..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/HasUnderlyingType.expected
+++ /dev/null
@@ -1,10 +0,0 @@
-#select
-| foo.ts:3:12:3:12 | x | foo.Bar in unknown scope |
-| foo.ts:4:10:4:10 | x | foo.Bar in unknown scope |
-| tst.ts:8:14:8:16 | arg | Base in global scope |
-| tst.ts:8:14:8:16 | arg | Sub in global scope |
-underlyingTypeNode
-| foo | | file://:0:0:0:0 | use moduleImport("foo").getMember("exports") |
-| foo | | file://:0:0:0:0 | use moduleImport("foo").getMember("exports").getMember("") |
-| foo | | foo.ts:1:8:1:10 | use moduleImport("foo").getMember("exports").getMember("default") |
-| foo | Bar | foo.ts:3:12:3:12 | use moduleImport("foo").getMember("exports").getMember("Bar").getInstance() |
diff --git a/javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/HasUnderlyingType.ql b/javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/HasUnderlyingType.ql
deleted file mode 100644
index 72d4e6d0f3d..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/HasUnderlyingType.ql
+++ /dev/null
@@ -1,9 +0,0 @@
-import javascript
-
-from Expr e, TypeName typeName
-where e.getType().hasUnderlyingTypeName(typeName)
-select e, typeName
-
-query API::Node underlyingTypeNode(string mod, string name) {
- result = API::Node::ofType(mod, name)
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/foo.ts b/javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/foo.ts
deleted file mode 100644
index 1b5be79068a..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/foo.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import foo from "foo";
-
-function f(x: foo.Bar) {
- return x;
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/tsconfig.json b/javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/tsconfig.json
deleted file mode 100644
index 4a2c2e62921..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/tsconfig.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "include": ["."]
-}
\ No newline at end of file
diff --git a/javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/tst.ts b/javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/tst.ts
deleted file mode 100644
index 02ca64296b5..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/HasUnderlyingType/tst.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-interface Base {
- x: T;
-}
-interface Sub extends Base {
- y: S;
-}
-
-function foo(arg: (Sub & {w: number}) | string) {
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/TypeNames.expected b/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/TypeNames.expected
deleted file mode 100644
index 3bca461afe2..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/TypeNames.expected
+++ /dev/null
@@ -1,22 +0,0 @@
-getTypeString
-| bar/client.ts:9:23:9:27 | Inter | Inter |
-| bar/client.ts:10:12:10:14 | Bar | Bar |
-| foo/index.ts:2:10:2:12 | Bar | Bar |
-| foo/index.ts:7:18:7:22 | Inter | Inter |
-| foo/index.ts:8:10:8:12 | Bar | Bar |
-importSpec
-| false | bar/client.ts:1:10:1:12 | Foo |
-| false | bar/client.ts:7:10:7:20 | Foo as Foo2 |
-| true | bar/client.ts:7:23:7:32 | type Inter |
-| true | bar/client.ts:7:35:7:42 | type Bar |
-#select
-| bar/client.ts:3:5:3:5 | f | my-awesome-package | Foo |
-| bar/client.ts:3:9:3:17 | new Foo() | my-awesome-package | Foo |
-| bar/client.ts:4:5:4:5 | b | my-awesome-package | Bar |
-| bar/client.ts:4:9:4:9 | f | my-awesome-package | Foo |
-| bar/client.ts:4:9:4:15 | f.bar() | my-awesome-package | Bar |
-| bar/client.ts:11:16:11:24 | new Foo() | my-awesome-package | Foo |
-| bar/client.ts:11:16:11:30 | new Foo().bar() | my-awesome-package | Bar |
-| foo/index.ts:1:14:1:16 | Foo | my-awesome-package | Foo |
-| foo/index.ts:2:23:2:31 | new Bar() | my-awesome-package | Bar |
-| foo/index.ts:5:14:5:16 | Bar | my-awesome-package | Bar |
diff --git a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/TypeNames.ql b/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/TypeNames.ql
deleted file mode 100644
index 1db3ef62aed..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/TypeNames.ql
+++ /dev/null
@@ -1,11 +0,0 @@
-import javascript
-
-query string getTypeString(TypeExpr te) { result = te.getType().toString() }
-
-query ImportSpecifier importSpec(boolean typeOnly) {
- if result.isTypeOnly() then typeOnly = true else typeOnly = false
-}
-
-from Expr e, string mod, string name
-where e.getType().(TypeReference).hasQualifiedName(mod, name)
-select e, mod, name
diff --git a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/bar/client.ts b/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/bar/client.ts
deleted file mode 100644
index 6e5d88b412e..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/bar/client.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { Foo } from "../foo";
-
-let f = new Foo();
-let b = f.bar();
-
-
-import { Foo as Foo2, type Inter, type Bar } from "../foo";
-
-class Impl implements Inter {
- bar(): Bar {
- return new Foo().bar();
- }
-}
\ No newline at end of file
diff --git a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/foo/index.ts b/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/foo/index.ts
deleted file mode 100644
index ee83e5fa92d..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/foo/index.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-export class Foo {
- bar(): Bar { return new Bar() }
-}
-
-export class Bar {}
-
-export interface Inter {
- bar(): Bar;
-}
\ No newline at end of file
diff --git a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/foo/package.json b/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/foo/package.json
deleted file mode 100644
index 0d82c265b2f..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/foo/package.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "name": "my-awesome-package"
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/tsconfig.json b/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/tsconfig.json
deleted file mode 100644
index 850cac831e7..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/ImportOwnPackage/tsconfig.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "include": ["foo", "bar"]
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/IndexTypes/test.expected b/javascript/ql/test/library-tests/TypeScript/IndexTypes/test.expected
deleted file mode 100644
index 4779b178e4f..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/IndexTypes/test.expected
+++ /dev/null
@@ -1,2 +0,0 @@
-| Foo | boolean |
-| typeof Foo in global scope | string |
diff --git a/javascript/ql/test/library-tests/TypeScript/IndexTypes/test.ql b/javascript/ql/test/library-tests/TypeScript/IndexTypes/test.ql
deleted file mode 100644
index ff6a2a4836f..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/IndexTypes/test.ql
+++ /dev/null
@@ -1,3 +0,0 @@
-import javascript
-
-query Type stringIndexType(Type t) { result = t.getStringIndexType() }
diff --git a/javascript/ql/test/library-tests/TypeScript/IndexTypes/tsconfig.json b/javascript/ql/test/library-tests/TypeScript/IndexTypes/tsconfig.json
deleted file mode 100644
index 9e26dfeeb6e..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/IndexTypes/tsconfig.json
+++ /dev/null
@@ -1 +0,0 @@
-{}
\ No newline at end of file
diff --git a/javascript/ql/test/library-tests/TypeScript/IndexTypes/tst.ts b/javascript/ql/test/library-tests/TypeScript/IndexTypes/tst.ts
deleted file mode 100644
index 9035ff2b2ac..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/IndexTypes/tst.ts
+++ /dev/null
@@ -1,8 +0,0 @@
- // static index signature
- class Foo {
- static hello = "world";
- static [n: string]: string;
- [n: string]: boolean;
- }
- Foo["whatever"] = "foo";
- new Foo()["something"] = true;
\ No newline at end of file
diff --git a/javascript/ql/test/library-tests/TypeScript/InfiniteTypes/recursiveMappedType.ts b/javascript/ql/test/library-tests/TypeScript/InfiniteTypes/recursiveMappedType.ts
deleted file mode 100644
index a3a47ab49ad..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/InfiniteTypes/recursiveMappedType.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-interface X {
- a: RecursiveMappedType & X;
- b: boolean;
-}
-
-type RecursiveMappedType = {
- [P in keyof V]?: X & RecursiveMappedType
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/InfiniteTypes/test.expected b/javascript/ql/test/library-tests/TypeScript/InfiniteTypes/test.expected
deleted file mode 100644
index 7a7033e01dd..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/InfiniteTypes/test.expected
+++ /dev/null
@@ -1,2 +0,0 @@
-| recursiveMappedType.ts:2:5:2:5 | a | RecursiveMappedType & X |
-| recursiveMappedType.ts:3:5:3:5 | b | boolean |
diff --git a/javascript/ql/test/library-tests/TypeScript/InfiniteTypes/test.ql b/javascript/ql/test/library-tests/TypeScript/InfiniteTypes/test.ql
deleted file mode 100644
index 574b7c54d4e..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/InfiniteTypes/test.ql
+++ /dev/null
@@ -1,4 +0,0 @@
-import javascript
-
-from Expr e
-select e, e.getType()
diff --git a/javascript/ql/test/library-tests/TypeScript/InfiniteTypes/tsconfig.json b/javascript/ql/test/library-tests/TypeScript/InfiniteTypes/tsconfig.json
deleted file mode 100644
index d144c8ddb02..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/InfiniteTypes/tsconfig.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "include": ["."]
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/LexicalTypes/TypeReferences.expected b/javascript/ql/test/library-tests/TypeScript/LexicalTypes/TypeReferences.expected
deleted file mode 100644
index 4e6e39d9f47..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/LexicalTypes/TypeReferences.expected
+++ /dev/null
@@ -1,16 +0,0 @@
-| C | 1 | bar.ts:10:10:10:24 | class C {} |
-| C | 1 | foo.ts:10:10:10:24 | class C {} |
-| C | 1 | bar.ts:10:10:10:24 | class C {} |
-| C | 1 | foo.ts:10:10:10:24 | class C {} |
-| ExportedClass | 1 | bar.ts:4:8:4:34 | class E ... Bar> {} |
-| ExportedClass | 1 | foo.ts:4:8:4:34 | class E ... Foo> {} |
-| ExportedClass | 1 | bar.ts:4:8:4:34 | class E ... Bar> {} |
-| ExportedClass | 1 | foo.ts:4:8:4:34 | class E ... Foo> {} |
-| InnerC | 1 | foo.ts:13:3:13:23 | class I ... oo1> {} |
-| InnerC | 1 | foo.ts:18:3:18:23 | class I ... oo2> {} |
-| InnerC | 1 | foo.ts:13:3:13:23 | class I ... oo1> {} |
-| InnerC | 1 | foo.ts:18:3:18:23 | class I ... oo2> {} |
-| LocalClass | 1 | bar.ts:3:1:3:24 | class L ... Bar> {} |
-| LocalClass | 1 | foo.ts:3:1:3:24 | class L ... Foo> {} |
-| LocalClass | 1 | bar.ts:3:1:3:24 | class L ... Bar> {} |
-| LocalClass | 1 | foo.ts:3:1:3:24 | class L ... Foo> {} |
diff --git a/javascript/ql/test/library-tests/TypeScript/LexicalTypes/TypeReferences.ql b/javascript/ql/test/library-tests/TypeScript/LexicalTypes/TypeReferences.ql
deleted file mode 100644
index 1609bba97f8..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/LexicalTypes/TypeReferences.ql
+++ /dev/null
@@ -1,4 +0,0 @@
-import javascript
-
-from TypeReference ref
-select ref, count(ref.getADefinition()), ref.getADefinition()
diff --git a/javascript/ql/test/library-tests/TypeScript/LexicalTypes/bar.ts b/javascript/ql/test/library-tests/TypeScript/LexicalTypes/bar.ts
deleted file mode 100644
index 7dcb2840fee..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/LexicalTypes/bar.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import * as dummy from "./dummy";
-
-class LocalClass {}
-export class ExportedClass {}
-
-let localBar = new LocalClass();
-let exportedBar = new ExportedClass();
-
-namespace LocalNamespace {
- export class C {}
- let barC = new C();
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/LexicalTypes/dummy.ts b/javascript/ql/test/library-tests/TypeScript/LexicalTypes/dummy.ts
deleted file mode 100644
index c6f5ebf6678..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/LexicalTypes/dummy.ts
+++ /dev/null
@@ -1 +0,0 @@
-export let x = 5;
diff --git a/javascript/ql/test/library-tests/TypeScript/LexicalTypes/foo.ts b/javascript/ql/test/library-tests/TypeScript/LexicalTypes/foo.ts
deleted file mode 100644
index a8e24920d87..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/LexicalTypes/foo.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import * as dummy from "./dummy";
-
-class LocalClass {}
-export class ExportedClass {}
-
-let localFoo = new LocalClass();
-let exportedFoo = new ExportedClass();
-
-namespace LocalNamespace {
- export class C {}
- let fooC = new C();
-
- class InnerC {}
- let innerFoo1 = new InnerC();
-}
-
-namespace LocalNamespace {
- class InnerC {}
- let innerFoo2 = new InnerC();
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/LexicalTypes/tsconfig.json b/javascript/ql/test/library-tests/TypeScript/LexicalTypes/tsconfig.json
deleted file mode 100644
index 0967ef424bc..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/LexicalTypes/tsconfig.json
+++ /dev/null
@@ -1 +0,0 @@
-{}
diff --git a/javascript/ql/test/library-tests/TypeScript/LiteralTypes/FloatLiteralTypes.expected b/javascript/ql/test/library-tests/TypeScript/LiteralTypes/FloatLiteralTypes.expected
deleted file mode 100644
index 55f7be1ebe8..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/LiteralTypes/FloatLiteralTypes.expected
+++ /dev/null
@@ -1,4 +0,0 @@
-| 32 | 32.0 |
-| 40.123 | 40.123 |
-| 45 | 45.0 |
-| 1099511627776 | 1.099511627776E12 |
diff --git a/javascript/ql/test/library-tests/TypeScript/LiteralTypes/FloatLiteralTypes.ql b/javascript/ql/test/library-tests/TypeScript/LiteralTypes/FloatLiteralTypes.ql
deleted file mode 100644
index d503725ac28..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/LiteralTypes/FloatLiteralTypes.ql
+++ /dev/null
@@ -1,4 +0,0 @@
-import javascript
-
-from NumberLiteralType type
-select type, type.getFloatValue()
diff --git a/javascript/ql/test/library-tests/TypeScript/LiteralTypes/IntLiteralTypes.expected b/javascript/ql/test/library-tests/TypeScript/LiteralTypes/IntLiteralTypes.expected
deleted file mode 100644
index 6abc5f39062..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/LiteralTypes/IntLiteralTypes.expected
+++ /dev/null
@@ -1,2 +0,0 @@
-| 32 | 32 |
-| 45 | 45 |
diff --git a/javascript/ql/test/library-tests/TypeScript/LiteralTypes/IntLiteralTypes.ql b/javascript/ql/test/library-tests/TypeScript/LiteralTypes/IntLiteralTypes.ql
deleted file mode 100644
index 7012836516e..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/LiteralTypes/IntLiteralTypes.ql
+++ /dev/null
@@ -1,4 +0,0 @@
-import javascript
-
-from NumberLiteralType type
-select type, type.getIntValue()
diff --git a/javascript/ql/test/library-tests/TypeScript/LiteralTypes/LiteralTypes.expected b/javascript/ql/test/library-tests/TypeScript/LiteralTypes/LiteralTypes.expected
deleted file mode 100644
index f0a26f40887..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/LiteralTypes/LiteralTypes.expected
+++ /dev/null
@@ -1,11 +0,0 @@
-| 32 | 32 |
-| 40.123 | 40.123 |
-| 45 | 45 |
-| 1099511627776 | 1099511627776 |
-| "31" | 31 |
-| "" | |
-| "A;B;C" | A;B;C |
-| "dsfg" | dsfg |
-| "sdfg" | sdfg |
-| false | false |
-| true | true |
diff --git a/javascript/ql/test/library-tests/TypeScript/LiteralTypes/LiteralTypes.ql b/javascript/ql/test/library-tests/TypeScript/LiteralTypes/LiteralTypes.ql
deleted file mode 100644
index 7c491d90ef4..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/LiteralTypes/LiteralTypes.ql
+++ /dev/null
@@ -1,4 +0,0 @@
-import javascript
-
-from LiteralType type
-select type, type.getStringValue()
diff --git a/javascript/ql/test/library-tests/TypeScript/LiteralTypes/tsconfig.json b/javascript/ql/test/library-tests/TypeScript/LiteralTypes/tsconfig.json
deleted file mode 100644
index d144c8ddb02..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/LiteralTypes/tsconfig.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "include": ["."]
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/LiteralTypes/tst.ts b/javascript/ql/test/library-tests/TypeScript/LiteralTypes/tst.ts
deleted file mode 100644
index ac75b4cf822..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/LiteralTypes/tst.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-let intValue = 45;
-let floatValue = 40.123;
-let hexValue = 0x20; // 32
-let intWith40Bits = 1099511627776;
-let stringValue = "dsfg";
-let stringValueType: "sdfg";
-let emptyStringType: "" = "";
-let semicolonString = "A;B;C";
-let numberStringValue = "31";
-let longStringValue = "very long string very long string very long string very long string very long string very long string very long string very long string very long string very long string";
-let trueValue = true;
-let falseValue = false;
diff --git a/javascript/ql/test/library-tests/TypeScript/NestedLiteral/test.expected b/javascript/ql/test/library-tests/TypeScript/NestedLiteral/test.expected
deleted file mode 100644
index 2504915fb03..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/NestedLiteral/test.expected
+++ /dev/null
@@ -1,36 +0,0 @@
-| tst.ts:2:3:2:6 | name | string |
-| tst.ts:3:3:3:10 | children | T[] |
-| tst.ts:6:5:6:11 | context | T |
-| tst.ts:6:18:17:1 | {\\n nam ... }\\n ]\\n} | T |
-| tst.ts:7:3:7:6 | name | string |
-| tst.ts:7:9:7:11 | 'x' | "x" |
-| tst.ts:8:3:8:10 | children | ({ name: string; } \| { name: string; children: ... |
-| tst.ts:8:13:16:3 | [\\n { ... }\\n ] | T[] |
-| tst.ts:9:5:9:18 | { name: 'x1' } | T |
-| tst.ts:9:7:9:10 | name | string |
-| tst.ts:9:13:9:16 | 'x1' | "x1" |
-| tst.ts:10:5:15:5 | {\\n ... ]\\n } | T |
-| tst.ts:11:7:11:10 | name | string |
-| tst.ts:11:13:11:16 | 'x2' | "x2" |
-| tst.ts:12:7:12:14 | children | { name: string; }[] |
-| tst.ts:12:17:14:7 | [\\n ... ] | T[] |
-| tst.ts:13:9:13:22 | { name: 'x3' } | T |
-| tst.ts:13:11:13:14 | name | string |
-| tst.ts:13:17:13:20 | 'x3' | "x3" |
-| tst.ts:19:5:19:13 | nocontext | { name: string; children: ({ name: string; chil... |
-| tst.ts:19:17:30:1 | {\\n nam ... }\\n ]\\n} | { name: string; children: ({ name: string; } \| ... |
-| tst.ts:20:3:20:6 | name | string |
-| tst.ts:20:9:20:11 | 'x' | "x" |
-| tst.ts:21:3:21:10 | children | ({ name: string; } \| { name: string; children: ... |
-| tst.ts:21:13:29:3 | [\\n { ... }\\n ] | ({ name: string; } \| { name: string; children: ... |
-| tst.ts:22:5:22:18 | { name: 'x1' } | { name: string; } |
-| tst.ts:22:7:22:10 | name | string |
-| tst.ts:22:13:22:16 | 'x1' | "x1" |
-| tst.ts:23:5:28:5 | {\\n ... ]\\n } | { name: string; children: { name: string; }[]; } |
-| tst.ts:24:7:24:10 | name | string |
-| tst.ts:24:13:24:16 | 'x2' | "x2" |
-| tst.ts:25:7:25:14 | children | { name: string; }[] |
-| tst.ts:25:17:27:7 | [\\n ... ] | { name: string; }[] |
-| tst.ts:26:9:26:22 | { name: 'x3' } | { name: string; } |
-| tst.ts:26:11:26:14 | name | string |
-| tst.ts:26:17:26:20 | 'x3' | "x3" |
diff --git a/javascript/ql/test/library-tests/TypeScript/NestedLiteral/test.ql b/javascript/ql/test/library-tests/TypeScript/NestedLiteral/test.ql
deleted file mode 100644
index 574b7c54d4e..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/NestedLiteral/test.ql
+++ /dev/null
@@ -1,4 +0,0 @@
-import javascript
-
-from Expr e
-select e, e.getType()
diff --git a/javascript/ql/test/library-tests/TypeScript/NestedLiteral/tsconfig.json b/javascript/ql/test/library-tests/TypeScript/NestedLiteral/tsconfig.json
deleted file mode 100644
index a0565aca758..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/NestedLiteral/tsconfig.json
+++ /dev/null
@@ -1 +0,0 @@
-{ "include": ["."] }
diff --git a/javascript/ql/test/library-tests/TypeScript/NestedLiteral/tst.ts b/javascript/ql/test/library-tests/TypeScript/NestedLiteral/tst.ts
deleted file mode 100644
index 65515c62e94..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/NestedLiteral/tst.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-interface T {
- name: string;
- children?: T[];
-}
-
-let context: T = {
- name: 'x',
- children: [
- { name: 'x1' },
- {
- name: 'x2',
- children: [
- { name: 'x3' }
- ]
- }
- ]
-}
-
-let nocontext = {
- name: 'x',
- children: [
- { name: 'x1' },
- {
- name: 'x2',
- children: [
- { name: 'x3' }
- ]
- }
- ]
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/Nullability/Types.expected b/javascript/ql/test/library-tests/TypeScript/Nullability/Types.expected
deleted file mode 100644
index 6db617b3e77..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/Nullability/Types.expected
+++ /dev/null
@@ -1,10 +0,0 @@
-exprType
-| tst.ts:1:5:1:16 | stringOrNUll | string \| null |
-| tst.ts:2:5:2:21 | stringOrUndefined | string \| undefined |
-| tst.ts:3:5:3:27 | stringO ... defined | string \| null \| undefined |
-| tst.ts:4:5:4:16 | stringOrVoid | string \| void |
-| tst.ts:7:5:7:21 | stringOrNullAlias | StringOrNullAlias |
-| tst.ts:8:5:8:32 | stringO ... defined | string \| null \| undefined |
-| tst.ts:10:5:10:23 | arrayOfStringOrNull | (string \| null)[] |
-unaliasedType
-| StringOrNullAlias | string \| null |
diff --git a/javascript/ql/test/library-tests/TypeScript/Nullability/Types.ql b/javascript/ql/test/library-tests/TypeScript/Nullability/Types.ql
deleted file mode 100644
index 0ca2bd6e15d..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/Nullability/Types.ql
+++ /dev/null
@@ -1,5 +0,0 @@
-import javascript
-
-query Type exprType(Expr e) { result = e.getType() }
-
-query Type unaliasedType(TypeAliasReference ref) { result = ref.getAliasedType() }
diff --git a/javascript/ql/test/library-tests/TypeScript/Nullability/tsconfig.json b/javascript/ql/test/library-tests/TypeScript/Nullability/tsconfig.json
deleted file mode 100644
index 6bb7671fa14..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/Nullability/tsconfig.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "include": ["."],
- "compilerOptions": {
- "strict": true
- }
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/Nullability/tst.ts b/javascript/ql/test/library-tests/TypeScript/Nullability/tst.ts
deleted file mode 100644
index f8ca1e565db..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/Nullability/tst.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-let stringOrNUll: string | null;
-let stringOrUndefined: string | undefined;
-let stringOrNullOrUndefined: string | null | undefined;
-let stringOrVoid: string | void;
-
-type StringOrNullAlias = string | null;
-let stringOrNullAlias: StringOrNullAlias;
-let stringOrNullAliasOrUndefined: StringOrNullAlias | undefined;
-
-let arrayOfStringOrNull: Array;
diff --git a/javascript/ql/test/library-tests/TypeScript/PathMapping/Imports.expected b/javascript/ql/test/library-tests/TypeScript/PathMapping/Imports.expected
deleted file mode 100644
index 886391b1455..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/PathMapping/Imports.expected
+++ /dev/null
@@ -1,11 +0,0 @@
-symbols
-| src/lib/foo.ts:1:1:4:0 | | src/lib/foo.ts |
-| src/lib/foo.ts:1:8:3:1 | functio ... 123;\\n} | foo in src/lib/foo.ts |
-| test/test_foo.ts:1:1:1:28 | import ... @/foo"; | src/lib/foo.ts |
-| test/test_foo.ts:1:1:7:0 | | test/test_foo.ts |
-| test/test_foo.ts:2:17:2:32 | require("@/foo") | src/lib/foo.ts |
-| test/test_foo.ts:4:1:4:5 | foo() | foo in src/lib/foo.ts |
-| test/test_foo.ts:6:1:6:12 | foolib.foo() | foo in src/lib/foo.ts |
-#select
-| test/test_foo.ts:1:1:1:28 | import ... @/foo"; | src/lib/foo.ts:1:1:4:0 | |
-| test/test_foo.ts:2:17:2:32 | require("@/foo") | src/lib/foo.ts:1:1:4:0 | |
diff --git a/javascript/ql/test/library-tests/TypeScript/PathMapping/Imports.ql b/javascript/ql/test/library-tests/TypeScript/PathMapping/Imports.ql
deleted file mode 100644
index 8f93f6f3734..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/PathMapping/Imports.ql
+++ /dev/null
@@ -1,6 +0,0 @@
-import javascript
-
-query predicate symbols(AstNode astNode, CanonicalName symbol) { ast_node_symbol(astNode, symbol) }
-
-from Import imprt
-select imprt, imprt.getImportedModule()
diff --git a/javascript/ql/test/library-tests/TypeScript/PathMapping/src/lib/foo.ts b/javascript/ql/test/library-tests/TypeScript/PathMapping/src/lib/foo.ts
deleted file mode 100644
index 0ef2bf692fd..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/PathMapping/src/lib/foo.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export function foo() {
- return 123;
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/PathMapping/test/test_foo.ts b/javascript/ql/test/library-tests/TypeScript/PathMapping/test/test_foo.ts
deleted file mode 100644
index d30f56c53e7..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/PathMapping/test/test_foo.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { foo } from "@/foo";
-import foolib = require("@/foo");
-
-foo();
-
-foolib.foo();
diff --git a/javascript/ql/test/library-tests/TypeScript/PathMapping/tsconfig.json b/javascript/ql/test/library-tests/TypeScript/PathMapping/tsconfig.json
deleted file mode 100644
index 476d1ad1ee5..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/PathMapping/tsconfig.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "include": ["."],
- "compilerOptions": {
- "baseUrl": ".",
- "paths": {
- "@/*": ["./src/lib/*"]
- }
- }
-}
diff --git a/javascript/ql/test/library-tests/TypeScript/PromiseType/DefinitelyTyped-LICENSE b/javascript/ql/test/library-tests/TypeScript/PromiseType/DefinitelyTyped-LICENSE
deleted file mode 100644
index c3ee6e73d57..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/PromiseType/DefinitelyTyped-LICENSE
+++ /dev/null
@@ -1,8 +0,0 @@
-This project is licensed under the MIT license.
-Copyrights are respective of each contributor listed at the beginning of each definition file.
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/javascript/ql/test/library-tests/TypeScript/PromiseType/PromiseType.expected b/javascript/ql/test/library-tests/TypeScript/PromiseType/PromiseType.expected
deleted file mode 100644
index 40c1f30e72a..00000000000
--- a/javascript/ql/test/library-tests/TypeScript/PromiseType/PromiseType.expected
+++ /dev/null
@@ -1,9 +0,0 @@
-| p1 | MyPromise | string |
-| p2 | MyPromise | any |
-| p3 | Promise | string |
-| p5 | PromiseLike