diff --git a/Cargo.lock b/Cargo.lock index e0baf57..d28db38 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,9 +10,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a" +checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" dependencies = [ "memchr", ] @@ -34,24 +34,23 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" +checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" [[package]] name = "anstyle-parse" @@ -73,9 +72,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c" +checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" dependencies = [ "anstyle", "windows-sys", @@ -87,17 +86,11 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "bitflags" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" - [[package]] name = "bstr" -version = "1.6.0" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" +checksum = "4c2f7349907b712260e64b0afe2f84692af14a454be26187d9df565c7f69266a" dependencies = [ "memchr", "serde", @@ -126,9 +119,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f" dependencies = [ "android-tzdata", "iana-time-zone", @@ -137,25 +130,24 @@ dependencies = [ "serde", "time", "wasm-bindgen", - "winapi", + "windows-targets", ] [[package]] name = "clap" -version = "4.3.24" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb690e81c7840c0d7aade59f242ea3b41b9bc27bcd5997890e7702ae4b32e487" +checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6" dependencies = [ "clap_builder", "clap_derive", - "once_cell", ] [[package]] name = "clap_builder" -version = "4.3.24" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ed2e96bc16d8d740f6f48d663eddf4b8a0983e79210fd55479b7bcd0a69860e" +checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" dependencies = [ "anstream", "anstyle", @@ -165,9 +157,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.3.12" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" +checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" dependencies = [ "heck", "proc-macro2", @@ -177,9 +169,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" [[package]] name = "codeql-extractor" @@ -214,7 +206,6 @@ dependencies = [ "tree-sitter", "tree-sitter-dockerfile", "tree-sitter-hcl", - "tree-sitter-json", ] [[package]] @@ -351,27 +342,6 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" -[[package]] -name = "errno" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "flate2" version = "1.0.27" @@ -436,17 +406,6 @@ dependencies = [ "cc", ] -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi", - "rustix", - "windows-sys", -] - [[package]] name = "itoa" version = "1.0.9" @@ -474,12 +433,6 @@ version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" -[[package]] -name = "linux-raw-sys" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" - [[package]] name = "log" version = "0.4.20" @@ -497,9 +450,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" [[package]] name = "memoffset" @@ -562,9 +515,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "pin-project-lite" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "proc-macro2" @@ -608,13 +561,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" +checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.7", + "regex-automata 0.3.8", "regex-syntax 0.7.5", ] @@ -629,9 +582,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" +checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" dependencies = [ "aho-corasick", "memchr", @@ -650,19 +603,6 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" -[[package]] -name = "rustix" -version = "0.38.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f" -dependencies = [ - "bitflags", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", -] - [[package]] name = "ryu" version = "1.0.15" @@ -677,18 +617,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.185" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be9b6f69f1dfd54c3b568ffa45c310d6973a5e5148fd40cf515acaf38cf5bc31" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.185" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc59dfdcbad1437773485e0367fea4b090a2e0a16d9ffc46af47764536a298ec" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", @@ -729,9 +669,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "2.0.29" +version = "2.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" +checksum = "718fa2415bcb8d8bd775917a1bf12a7931b6dfa890753378538118181e0cb398" dependencies = [ "proc-macro2", "quote", @@ -849,15 +789,6 @@ dependencies = [ "tree-sitter", ] -[[package]] -name = "tree-sitter-json" -version = "0.20.0" -source = "git+https://github.com/tausbn/tree-sitter-json.git?rev=745663ee997f1576fe1e7187e6347e0db36ec7a9#745663ee997f1576fe1e7187e6347e0db36ec7a9" -dependencies = [ - "cc", - "tree-sitter", -] - [[package]] name = "unicode-ident" version = "1.0.11" diff --git a/extractor/Cargo.toml b/extractor/Cargo.toml index 7eb87e6..bdbfaed 100644 --- a/extractor/Cargo.toml +++ b/extractor/Cargo.toml @@ -11,7 +11,6 @@ flate2 = "1.0" tree-sitter = ">= 0.20, < 0.21" tree-sitter-hcl = { git = "https://github.com/GeekMasher/tree-sitter-hcl", rev = "5e045dd1ff7852511c249c4c5d919d9556751d98" } -tree-sitter-json = { git = "https://github.com/tausbn/tree-sitter-json.git", rev = "745663ee997f1576fe1e7187e6347e0db36ec7a9" } tree-sitter-dockerfile = { git = "https://github.com/GeekMasher/tree-sitter-dockerfile", rev = "c0a9d694d9bf8ab79a919f5f9c7bc9c169caf321" } clap = { version = "4.2", features = ["derive"] } tracing = "0.1" diff --git a/extractor/src/autobuilder.rs b/extractor/src/autobuilder.rs index bf23ead..9b69ea5 100644 --- a/extractor/src/autobuilder.rs +++ b/extractor/src/autobuilder.rs @@ -17,10 +17,7 @@ pub fn run(_: Options) -> std::io::Result<()> { .include_extensions(&[ ".hcl", ".tf", - ".ftvars", // Terraform / HCL files - ".json", - ".jsonc", - ".jsonl", // JSON files + ".ftvars", // Terraform / HCL files ".Dockerfile", // Docker files ]) .include_globs(&[ diff --git a/extractor/src/extractor.rs b/extractor/src/extractor.rs index 9e90b95..7eb47a1 100644 --- a/extractor/src/extractor.rs +++ b/extractor/src/extractor.rs @@ -36,12 +36,6 @@ pub fn run(options: Options) -> std::io::Result<()> { node_types: tree_sitter_hcl::NODE_TYPES, file_globs: vec!["*.hcl".into(), "*.tf".into(), "*.tfvar".into()], }, - simple::LanguageSpec { - prefix: "json", - ts_language: tree_sitter_json::language(), - node_types: tree_sitter_json::NODE_TYPES, - file_globs: vec!["*.json".into(), "*.jsonl".into(), "*.jsonc".into()], - }, simple::LanguageSpec { prefix: "dockerfile", ts_language: tree_sitter_dockerfile::language(), diff --git a/extractor/src/generator.rs b/extractor/src/generator.rs index c19935a..538055c 100644 --- a/extractor/src/generator.rs +++ b/extractor/src/generator.rs @@ -27,10 +27,6 @@ pub fn run(options: Options) -> std::io::Result<()> { name: "HCL".to_owned(), node_types: tree_sitter_hcl::NODE_TYPES, }, - Language { - name: "JSON".to_owned(), - node_types: tree_sitter_json::NODE_TYPES, - }, Language { name: "DOCKERFILE".to_owned(), node_types: tree_sitter_dockerfile::NODE_TYPES, diff --git a/ql/lib/codeql/iac/ast/Json.qll b/ql/lib/codeql/iac/ast/Json.qll deleted file mode 100644 index e69de29..0000000 diff --git a/ql/lib/codeql/iac/ast/internal/AstNodes.qll b/ql/lib/codeql/iac/ast/internal/AstNodes.qll index 00606d7..c6c2e1b 100644 --- a/ql/lib/codeql/iac/ast/internal/AstNodes.qll +++ b/ql/lib/codeql/iac/ast/internal/AstNodes.qll @@ -1,7 +1,6 @@ private import TreeSitter import Hcl import Container -import Json /** * AST Common Type @@ -9,5 +8,4 @@ import Json cached newtype TAstNode = THclAstNode(HCL::AstNode node) or - TContainerAstNode(DOCKERFILE::AstNode node) or - TJsonAstNode(JSON::AstNode node) + TContainerAstNode(DOCKERFILE::AstNode node) diff --git a/ql/lib/codeql/iac/ast/internal/Json.qll b/ql/lib/codeql/iac/ast/internal/Json.qll deleted file mode 100644 index f457dbd..0000000 --- a/ql/lib/codeql/iac/ast/internal/Json.qll +++ /dev/null @@ -1,45 +0,0 @@ -import TreeSitter - -/** - * JSON Ast Nodes - */ -cached -newtype TJsonAstNode = - TJsonReservedWord(JSON::ReservedWord node) or - TJsonComment(JSON::Comment node) or - TJsonArray(JSON::Array node) or - TJsonDocument(JSON::Document node) or - TJsonFalse(JSON::False node) or - TJsonTrue(JSON::True node) or - TJsonNull(JSON::Null node) or - TJsonNumber(JSON::Number node) or - TJsonObject(JSON::Object node) or - TJsonPair(JSON::Pair node) or - TJsonString(JSON::String node) or - TJsonStringContent(JSON::StringContent node) or - TJsonValue(JSON::Value node) - -class TJsonBooleanLiteral = TJsonFalse or TJsonTrue; - -class TJsonLiteral = TJsonBooleanLiteral or TJsonNumber or TJsonString or TJsonNull; - -/** - * Gets TJsonhe underlying TJsonreeSitter entity for a given AST node. - */ -cached -JSON::AstNode toJsonTreeSitter(TJsonAstNode n) { - // n = TJsonAttribute(result) or - n = TJsonReservedWord(result) or - n = TJsonComment(result) or - n = TJsonArray(result) or - n = TJsonDocument(result) or - n = TJsonFalse(result) or - n = TJsonTrue(result) or - n = TJsonNull(result) or - n = TJsonNumber(result) or - n = TJsonObject(result) or - n = TJsonPair(result) or - n = TJsonString(result) or - n = TJsonStringContent(result) or - n = TJsonValue(result) -} diff --git a/ql/lib/codeql/iac/ast/internal/TreeSitter.qll b/ql/lib/codeql/iac/ast/internal/TreeSitter.qll index 55e6101..d74777c 100644 --- a/ql/lib/codeql/iac/ast/internal/TreeSitter.qll +++ b/ql/lib/codeql/iac/ast/internal/TreeSitter.qll @@ -620,153 +620,6 @@ module HCL { } } -module JSON { - /** The base class for all AST nodes */ - class AstNode extends @json_ast_node { - /** Gets a string representation of this element. */ - string toString() { result = this.getAPrimaryQlClass() } - - /** Gets the location of this element. */ - final L::Location getLocation() { json_ast_node_info(this, _, _, result) } - - /** Gets the parent of this element. */ - final AstNode getParent() { json_ast_node_info(this, result, _, _) } - - /** Gets the index of this node among the children of its parent. */ - final int getParentIndex() { json_ast_node_info(this, _, result, _) } - - /** Gets a field or child node of this node. */ - AstNode getAFieldOrChild() { none() } - - /** Gets the name of the primary QL class for this element. */ - string getAPrimaryQlClass() { result = "???" } - - /** Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs. */ - string getPrimaryQlClasses() { result = concat(this.getAPrimaryQlClass(), ",") } - } - - /** A token. */ - class Token extends @json_token, AstNode { - /** Gets the value of this token. */ - final string getValue() { json_tokeninfo(this, _, result) } - - /** Gets a string representation of this element. */ - final override string toString() { result = this.getValue() } - - /** Gets the name of the primary QL class for this element. */ - override string getAPrimaryQlClass() { result = "Token" } - } - - /** A reserved word. */ - class ReservedWord extends @json_reserved_word, Token { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "ReservedWord" } - } - - /** A class representing `array` nodes. */ - class Array extends @json_array, AstNode { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "Array" } - - /** Gets the `i`th child of this node. */ - final Value getChild(int i) { json_array_child(this, i, result) } - - /** Gets a field or child node of this node. */ - final override AstNode getAFieldOrChild() { json_array_child(this, _, result) } - } - - /** A class representing `comment` tokens. */ - class Comment extends @json_token_comment, Token { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "Comment" } - } - - /** A class representing `document` nodes. */ - class Document extends @json_document, AstNode { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "Document" } - - /** Gets the `i`th child of this node. */ - final Value getChild(int i) { json_document_child(this, i, result) } - - /** Gets a field or child node of this node. */ - final override AstNode getAFieldOrChild() { json_document_child(this, _, result) } - } - - /** A class representing `false` tokens. */ - class False extends @json_token_false, Token { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "False" } - } - - /** A class representing `null` tokens. */ - class Null extends @json_token_null, Token { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "Null" } - } - - /** A class representing `number` tokens. */ - class Number extends @json_token_number, Token { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "Number" } - } - - /** A class representing `object` nodes. */ - class Object extends @json_object, AstNode { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "Object" } - - /** Gets the `i`th child of this node. */ - final Pair getChild(int i) { json_object_child(this, i, result) } - - /** Gets a field or child node of this node. */ - final override AstNode getAFieldOrChild() { json_object_child(this, _, result) } - } - - /** A class representing `pair` nodes. */ - class Pair extends @json_pair, AstNode { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "Pair" } - - /** Gets the node corresponding to the field `key`. */ - final AstNode getKey() { json_pair_def(this, result, _) } - - /** Gets the node corresponding to the field `value`. */ - final Value getValue() { json_pair_def(this, _, result) } - - /** Gets a field or child node of this node. */ - final override AstNode getAFieldOrChild() { - json_pair_def(this, result, _) or json_pair_def(this, _, result) - } - } - - /** A class representing `string` nodes. */ - class String extends @json_string__, AstNode { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "String" } - - /** Gets the child of this node. */ - final StringContent getChild() { json_string_child(this, result) } - - /** Gets a field or child node of this node. */ - final override AstNode getAFieldOrChild() { json_string_child(this, result) } - } - - /** A class representing `string_content` tokens. */ - class StringContent extends @json_token_string_content, Token { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "StringContent" } - } - - /** A class representing `true` tokens. */ - class True extends @json_token_true, Token { - /** Gets the name of the primary QL class for this element. */ - final override string getAPrimaryQlClass() { result = "True" } - } - - class Value extends @json_value, AstNode { } -} - module DOCKERFILE { /** The base class for all AST nodes */ class AstNode extends @dockerfile_ast_node { diff --git a/ql/lib/iac.dbscheme b/ql/lib/iac.dbscheme index 4568e6d..74fb276 100644 --- a/ql/lib/iac.dbscheme +++ b/ql/lib/iac.dbscheme @@ -496,88 +496,6 @@ hcl_ast_node_info( int loc: @location_default ref ); -/*- JSON dbscheme -*/ -#keyset[json_array, index] -json_array_child( - int json_array: @json_array ref, - int index: int ref, - unique int child: @json_value ref -); - -json_array_def( - unique int id: @json_array -); - -#keyset[json_document, index] -json_document_child( - int json_document: @json_document ref, - int index: int ref, - unique int child: @json_value ref -); - -json_document_def( - unique int id: @json_document -); - -#keyset[json_object, index] -json_object_child( - int json_object: @json_object ref, - int index: int ref, - unique int child: @json_pair ref -); - -json_object_def( - unique int id: @json_object -); - -@json_pair_key_type = @json_string__ | @json_token_number - -json_pair_def( - unique int id: @json_pair, - int key__: @json_pair_key_type ref, - int value: @json_value ref -); - -json_string_child( - unique int json_string__: @json_string__ ref, - unique int child: @json_token_string_content ref -); - -json_string_def( - unique int id: @json_string__ -); - -@json_value = @json_array | @json_object | @json_string__ | @json_token_false | @json_token_null | @json_token_number | @json_token_true - -json_tokeninfo( - unique int id: @json_token, - int kind: int ref, - string value: string ref -); - -case @json_token.kind of - 0 = @json_reserved_word -| 1 = @json_token_comment -| 2 = @json_token_false -| 3 = @json_token_null -| 4 = @json_token_number -| 5 = @json_token_string_content -| 6 = @json_token_true -; - - -@json_ast_node = @json_array | @json_document | @json_object | @json_pair | @json_string__ | @json_token - -@json_ast_node_parent = @file | @json_ast_node - -#keyset[parent, parent_index] -json_ast_node_info( - unique int node: @json_ast_node ref, - int parent: @json_ast_node_parent ref, - int parent_index: int ref, - int loc: @location_default ref -); - /*- DOCKERFILE dbscheme -*/ @dockerfile_add_instruction_child_type = @dockerfile_path | @dockerfile_token_param diff --git a/ql/test/library-tests/yaml/ast/AST.expected b/ql/test/library-tests/yaml/ast/AST.expected index 3adcba8..62b5ced 100644 --- a/ql/test/library-tests/yaml/ast/AST.expected +++ b/ql/test/library-tests/yaml/ast/AST.expected @@ -11,6 +11,17 @@ | Chart.yml:6:10:6:14 | 0.1.0 | | Chart.yml:7:1:7:10 | appVersion | | Chart.yml:7:13:7:20 | "1.16.0" | +| sample.json:1:1:8:1 | { | +| sample.json:2:5:2:10 | "this" | +| sample.json:2:13:2:16 | "is" | +| sample.json:3:5:3:7 | "a" | +| sample.json:3:10:6:5 | { | +| sample.json:4:9:4:16 | "sample" | +| sample.json:4:19:4:24 | "json" | +| sample.json:5:9:5:14 | "file" | +| sample.json:5:17:5:17 | 4 | +| sample.json:7:5:7:13 | "testing" | +| sample.json:7:16:7:19 | true | | sample.yml:1:1:1:4 | this | | sample.yml:1:1:6:11 | this: is | | sample.yml:1:7:1:8 | is | diff --git a/ql/test/library-tests/yaml/ast/sample.json b/ql/test/library-tests/yaml/ast/sample.json new file mode 100644 index 0000000..ced6677 --- /dev/null +++ b/ql/test/library-tests/yaml/ast/sample.json @@ -0,0 +1,8 @@ +{ + "this": "is", + "a": { + "sample": "json", + "file": 4 + }, + "testing": true +} \ No newline at end of file diff --git a/rust-toolchain.toml b/rust-toolchain.toml index abe442a..22fab33 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.68" +channel = "1.70" profile = "minimal" components = ["rustfmt"] diff --git a/tools/pre-finalize.sh b/tools/pre-finalize.sh index 6678cc4..a881cb5 100755 --- a/tools/pre-finalize.sh +++ b/tools/pre-finalize.sh @@ -5,6 +5,9 @@ set -eu "$CODEQL_DIST/codeql" database index-files \ "--include=**/*.yml" \ "--include=**/*.yaml" \ + "--include=**/*.json" \ + "--include=**/*.jsonc" \ + "--include=**/*.jsonl" \ --size-limit=5m \ --language yaml \ -- \ diff --git a/tools/qltest.sh b/tools/qltest.sh index 056f50d..a8d78a5 100755 --- a/tools/qltest.sh +++ b/tools/qltest.sh @@ -14,6 +14,8 @@ set -eu exec "${CODEQL_DIST}/codeql" database index-files \ --prune="**/*.testproj" \ --include-extension=.yml \ + --include-extension=.yaml \ + --include-extension=.json \ --size-limit=5m \ --language=yaml \ --working-dir=.\