Skip to content

Commit 2bbf1e3

Browse files
authored
QL: Add support for dbscheme and qlpack.yml
Currently the the YAML "parser" fails for some legacy files, but the actual files appear to be parsed correctly.
1 parent 63c7b21 commit 2bbf1e3

8 files changed

Lines changed: 496 additions & 30 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

extractor/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ edition = "2018"
1010
flate2 = "1.0"
1111
node-types = { path = "../node-types" }
1212
tree-sitter = "0.19"
13-
tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "ef46f6c4c076cc06bb206686794cec26b5c544a7" }
13+
tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "e08901378e2fd5c33f1e88bbb59716fd36f094f7" }
1414
clap = "2.33"
1515
tracing = "0.1"
1616
tracing-subscriber = { version = "0.2", features = ["env-filter"] }

generator/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ edition = "2018"
1010
node-types = { path = "../node-types" }
1111
tracing = "0.1"
1212
tracing-subscriber = { version = "0.2", features = ["env-filter"] }
13-
tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "ef46f6c4c076cc06bb206686794cec26b5c544a7" }
13+
tree-sitter-ql = { git = "https://github.com/tausbn/tree-sitter-ql.git", rev = "e08901378e2fd5c33f1e88bbb59716fd36f094f7" }

ql/src/codeql_ql/ast/Ast.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class TopLevel extends TTopLevel, AstNode {
7777
* Gets a member from contained in this top-level module.
7878
* Includes private members.
7979
*/
80-
ModuleMember getAMember() { toGenerated(result) = file.getChild(_).getChild(_) }
80+
ModuleMember getAMember() { toGenerated(result) = file.getChild(_).(Generated::ModuleMember).getChild(_) }
8181

8282
override ModuleMember getAChild(string pred) {
8383
pred = directMember("getAMember") and result = this.getAMember()

ql/src/codeql_ql/ast/internal/TreeSitter.qll

Lines changed: 294 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,273 @@ module Generated {
438438
override AstNode getAFieldOrChild() { datatype_branches_child(this, _, result) }
439439
}
440440

441+
/** A class representing `db_annotation` nodes. */
442+
class DbAnnotation extends @db_annotation, AstNode {
443+
/** Gets the name of the primary QL class for this element. */
444+
override string getAPrimaryQlClass() { result = "DbAnnotation" }
445+
446+
/** Gets the location of this element. */
447+
override Location getLocation() { db_annotation_def(this, result) }
448+
449+
/** Gets the node corresponding to the field `argsAnnotation`. */
450+
DbArgsAnnotation getArgsAnnotation() { db_annotation_args_annotation(this, result) }
451+
452+
/** Gets the node corresponding to the field `simpleAnnotation`. */
453+
AnnotName getSimpleAnnotation() { db_annotation_simple_annotation(this, result) }
454+
455+
/** Gets a field or child node of this node. */
456+
override AstNode getAFieldOrChild() {
457+
db_annotation_args_annotation(this, result) or db_annotation_simple_annotation(this, result)
458+
}
459+
}
460+
461+
/** A class representing `db_argsAnnotation` nodes. */
462+
class DbArgsAnnotation extends @db_args_annotation, AstNode {
463+
/** Gets the name of the primary QL class for this element. */
464+
override string getAPrimaryQlClass() { result = "DbArgsAnnotation" }
465+
466+
/** Gets the location of this element. */
467+
override Location getLocation() { db_args_annotation_def(this, _, result) }
468+
469+
/** Gets the node corresponding to the field `name`. */
470+
AnnotName getName() { db_args_annotation_def(this, result, _) }
471+
472+
SimpleId getChild(int i) { db_args_annotation_child(this, i, result) }
473+
474+
/** Gets a field or child node of this node. */
475+
override AstNode getAFieldOrChild() {
476+
db_args_annotation_def(this, result, _) or db_args_annotation_child(this, _, result)
477+
}
478+
}
479+
480+
/** A class representing `db_boolean` tokens. */
481+
class DbBoolean extends @token_db_boolean, Token {
482+
/** Gets the name of the primary QL class for this element. */
483+
override string getAPrimaryQlClass() { result = "DbBoolean" }
484+
}
485+
486+
/** A class representing `db_branch` nodes. */
487+
class DbBranch extends @db_branch, AstNode {
488+
/** Gets the name of the primary QL class for this element. */
489+
override string getAPrimaryQlClass() { result = "DbBranch" }
490+
491+
/** Gets the location of this element. */
492+
override Location getLocation() { db_branch_def(this, result) }
493+
494+
/** Gets the node corresponding to the field `qldoc`. */
495+
Qldoc getQldoc() { db_branch_qldoc(this, result) }
496+
497+
AstNode getChild(int i) { db_branch_child(this, i, result) }
498+
499+
/** Gets a field or child node of this node. */
500+
override AstNode getAFieldOrChild() {
501+
db_branch_qldoc(this, result) or db_branch_child(this, _, result)
502+
}
503+
}
504+
505+
/** A class representing `db_case` tokens. */
506+
class DbCase extends @token_db_case, Token {
507+
/** Gets the name of the primary QL class for this element. */
508+
override string getAPrimaryQlClass() { result = "DbCase" }
509+
}
510+
511+
/** A class representing `db_caseDecl` nodes. */
512+
class DbCaseDecl extends @db_case_decl, AstNode {
513+
/** Gets the name of the primary QL class for this element. */
514+
override string getAPrimaryQlClass() { result = "DbCaseDecl" }
515+
516+
/** Gets the location of this element. */
517+
override Location getLocation() { db_case_decl_def(this, _, _, result) }
518+
519+
/** Gets the node corresponding to the field `base`. */
520+
Dbtype getBase() { db_case_decl_def(this, result, _, _) }
521+
522+
/** Gets the node corresponding to the field `discriminator`. */
523+
SimpleId getDiscriminator() { db_case_decl_def(this, _, result, _) }
524+
525+
AstNode getChild(int i) { db_case_decl_child(this, i, result) }
526+
527+
/** Gets a field or child node of this node. */
528+
override AstNode getAFieldOrChild() {
529+
db_case_decl_def(this, result, _, _) or
530+
db_case_decl_def(this, _, result, _) or
531+
db_case_decl_child(this, _, result)
532+
}
533+
}
534+
535+
/** A class representing `db_colType` nodes. */
536+
class DbColType extends @db_col_type, AstNode {
537+
/** Gets the name of the primary QL class for this element. */
538+
override string getAPrimaryQlClass() { result = "DbColType" }
539+
540+
/** Gets the location of this element. */
541+
override Location getLocation() { db_col_type_def(this, _, result) }
542+
543+
AstNode getChild() { db_col_type_def(this, result, _) }
544+
545+
/** Gets a field or child node of this node. */
546+
override AstNode getAFieldOrChild() { db_col_type_def(this, result, _) }
547+
}
548+
549+
/** A class representing `db_column` nodes. */
550+
class DbColumn extends @db_column, AstNode {
551+
/** Gets the name of the primary QL class for this element. */
552+
override string getAPrimaryQlClass() { result = "DbColumn" }
553+
554+
/** Gets the location of this element. */
555+
override Location getLocation() { db_column_def(this, _, _, _, result) }
556+
557+
/** Gets the node corresponding to the field `colName`. */
558+
SimpleId getColName() { db_column_def(this, result, _, _, _) }
559+
560+
/** Gets the node corresponding to the field `colType`. */
561+
DbColType getColType() { db_column_def(this, _, result, _, _) }
562+
563+
/** Gets the node corresponding to the field `isRef`. */
564+
DbRef getIsRef() { db_column_is_ref(this, result) }
565+
566+
/** Gets the node corresponding to the field `isUnique`. */
567+
DbUnique getIsUnique() { db_column_is_unique(this, result) }
568+
569+
/** Gets the node corresponding to the field `qldoc`. */
570+
Qldoc getQldoc() { db_column_qldoc(this, result) }
571+
572+
/** Gets the node corresponding to the field `reprType`. */
573+
DbReprType getReprType() { db_column_def(this, _, _, result, _) }
574+
575+
/** Gets a field or child node of this node. */
576+
override AstNode getAFieldOrChild() {
577+
db_column_def(this, result, _, _, _) or
578+
db_column_def(this, _, result, _, _) or
579+
db_column_is_ref(this, result) or
580+
db_column_is_unique(this, result) or
581+
db_column_qldoc(this, result) or
582+
db_column_def(this, _, _, result, _)
583+
}
584+
}
585+
586+
/** A class representing `db_date` tokens. */
587+
class DbDate extends @token_db_date, Token {
588+
/** Gets the name of the primary QL class for this element. */
589+
override string getAPrimaryQlClass() { result = "DbDate" }
590+
}
591+
592+
/** A class representing `db_entry` nodes. */
593+
class DbEntry extends @db_entry, AstNode {
594+
/** Gets the name of the primary QL class for this element. */
595+
override string getAPrimaryQlClass() { result = "DbEntry" }
596+
597+
/** Gets the location of this element. */
598+
override Location getLocation() { db_entry_def(this, _, result) }
599+
600+
AstNode getChild() { db_entry_def(this, result, _) }
601+
602+
/** Gets a field or child node of this node. */
603+
override AstNode getAFieldOrChild() { db_entry_def(this, result, _) }
604+
}
605+
606+
/** A class representing `db_float` tokens. */
607+
class DbFloat extends @token_db_float, Token {
608+
/** Gets the name of the primary QL class for this element. */
609+
override string getAPrimaryQlClass() { result = "DbFloat" }
610+
}
611+
612+
/** A class representing `db_int` tokens. */
613+
class DbInt extends @token_db_int, Token {
614+
/** Gets the name of the primary QL class for this element. */
615+
override string getAPrimaryQlClass() { result = "DbInt" }
616+
}
617+
618+
/** A class representing `db_ref` tokens. */
619+
class DbRef extends @token_db_ref, Token {
620+
/** Gets the name of the primary QL class for this element. */
621+
override string getAPrimaryQlClass() { result = "DbRef" }
622+
}
623+
624+
/** A class representing `db_reprType` nodes. */
625+
class DbReprType extends @db_repr_type, AstNode {
626+
/** Gets the name of the primary QL class for this element. */
627+
override string getAPrimaryQlClass() { result = "DbReprType" }
628+
629+
/** Gets the location of this element. */
630+
override Location getLocation() { db_repr_type_def(this, result) }
631+
632+
AstNode getChild(int i) { db_repr_type_child(this, i, result) }
633+
634+
/** Gets a field or child node of this node. */
635+
override AstNode getAFieldOrChild() { db_repr_type_child(this, _, result) }
636+
}
637+
638+
/** A class representing `db_string` tokens. */
639+
class DbString extends @token_db_string, Token {
640+
/** Gets the name of the primary QL class for this element. */
641+
override string getAPrimaryQlClass() { result = "DbString" }
642+
}
643+
644+
/** A class representing `db_table` nodes. */
645+
class DbTable extends @db_table, AstNode {
646+
/** Gets the name of the primary QL class for this element. */
647+
override string getAPrimaryQlClass() { result = "DbTable" }
648+
649+
/** Gets the location of this element. */
650+
override Location getLocation() { db_table_def(this, _, result) }
651+
652+
/** Gets the node corresponding to the field `tableName`. */
653+
DbTableName getTableName() { db_table_def(this, result, _) }
654+
655+
AstNode getChild(int i) { db_table_child(this, i, result) }
656+
657+
/** Gets a field or child node of this node. */
658+
override AstNode getAFieldOrChild() {
659+
db_table_def(this, result, _) or db_table_child(this, _, result)
660+
}
661+
}
662+
663+
/** A class representing `db_tableName` nodes. */
664+
class DbTableName extends @db_table_name, AstNode {
665+
/** Gets the name of the primary QL class for this element. */
666+
override string getAPrimaryQlClass() { result = "DbTableName" }
667+
668+
/** Gets the location of this element. */
669+
override Location getLocation() { db_table_name_def(this, _, result) }
670+
671+
SimpleId getChild() { db_table_name_def(this, result, _) }
672+
673+
/** Gets a field or child node of this node. */
674+
override AstNode getAFieldOrChild() { db_table_name_def(this, result, _) }
675+
}
676+
677+
/** A class representing `db_unionDecl` nodes. */
678+
class DbUnionDecl extends @db_union_decl, AstNode {
679+
/** Gets the name of the primary QL class for this element. */
680+
override string getAPrimaryQlClass() { result = "DbUnionDecl" }
681+
682+
/** Gets the location of this element. */
683+
override Location getLocation() { db_union_decl_def(this, _, result) }
684+
685+
/** Gets the node corresponding to the field `base`. */
686+
Dbtype getBase() { db_union_decl_def(this, result, _) }
687+
688+
Dbtype getChild(int i) { db_union_decl_child(this, i, result) }
689+
690+
/** Gets a field or child node of this node. */
691+
override AstNode getAFieldOrChild() {
692+
db_union_decl_def(this, result, _) or db_union_decl_child(this, _, result)
693+
}
694+
}
695+
696+
/** A class representing `db_unique` tokens. */
697+
class DbUnique extends @token_db_unique, Token {
698+
/** Gets the name of the primary QL class for this element. */
699+
override string getAPrimaryQlClass() { result = "DbUnique" }
700+
}
701+
702+
/** A class representing `db_varchar` tokens. */
703+
class DbVarchar extends @token_db_varchar, Token {
704+
/** Gets the name of the primary QL class for this element. */
705+
override string getAPrimaryQlClass() { result = "DbVarchar" }
706+
}
707+
441708
/** A class representing `dbtype` tokens. */
442709
class Dbtype extends @token_dbtype, Token {
443710
/** Gets the name of the primary QL class for this element. */
@@ -995,7 +1262,7 @@ module Generated {
9951262
/** Gets the location of this element. */
9961263
override Location getLocation() { ql_def(this, result) }
9971264

998-
ModuleMember getChild(int i) { ql_child(this, i, result) }
1265+
AstNode getChild(int i) { ql_child(this, i, result) }
9991266

10001267
/** Gets a field or child node of this node. */
10011268
override AstNode getAFieldOrChild() { ql_child(this, _, result) }
@@ -1345,4 +1612,30 @@ module Generated {
13451612
/** Gets a field or child node of this node. */
13461613
override AstNode getAFieldOrChild() { variable_def(this, result, _) }
13471614
}
1615+
1616+
/** A class representing `yaml_entry` nodes. */
1617+
class YamlEntry extends @yaml_entry, AstNode {
1618+
/** Gets the name of the primary QL class for this element. */
1619+
override string getAPrimaryQlClass() { result = "YamlEntry" }
1620+
1621+
/** Gets the location of this element. */
1622+
override Location getLocation() { yaml_entry_def(this, _, _, result) }
1623+
1624+
/** Gets the node corresponding to the field `key`. */
1625+
SimpleId getKey() { yaml_entry_def(this, result, _, _) }
1626+
1627+
/** Gets the node corresponding to the field `value`. */
1628+
YamlValue getValue() { yaml_entry_def(this, _, result, _) }
1629+
1630+
/** Gets a field or child node of this node. */
1631+
override AstNode getAFieldOrChild() {
1632+
yaml_entry_def(this, result, _, _) or yaml_entry_def(this, _, result, _)
1633+
}
1634+
}
1635+
1636+
/** A class representing `yaml_value` tokens. */
1637+
class YamlValue extends @token_yaml_value, Token {
1638+
/** Gets the name of the primary QL class for this element. */
1639+
override string getAPrimaryQlClass() { result = "YamlValue" }
1640+
}
13481641
}

0 commit comments

Comments
 (0)