Skip to content

Commit 743eca7

Browse files
authored
Merge pull request #15 from github/aibaars/ql-folder
Add QL folder structure
2 parents 553e1ab + 638fd91 commit 743eca7

16 files changed

+38881
-7
lines changed

.github/workflows/build.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ jobs:
4545
if: ${{ matrix.os == 'ubuntu-latest' }}
4646
with:
4747
name: ruby.dbscheme
48-
path: ruby.dbscheme
48+
path: ql/src/ruby.dbscheme
4949
- uses: actions/upload-artifact@v2
5050
if: ${{ matrix.os == 'ubuntu-latest' }}
5151
with:
5252
name: ruby_ast.qll
53-
path: ruby_ast.qll
53+
path: ql/src/codeql_ruby/ast.qll
5454
- uses: actions/upload-artifact@v2
5555
with:
5656
name: extractor-${{ matrix.os }}
@@ -81,7 +81,7 @@ jobs:
8181
path: osx64
8282
- run: |
8383
mkdir -p ruby
84-
cp -r codeql-extractor.yml tools ruby/
84+
cp -r codeql-extractor.yml tools ql/src/ruby.dbscheme.stats ruby/
8585
mkdir -p ruby/tools/{linux64,osx64,win64}
8686
cp linux64/ruby-extractor ruby/tools/linux64/extractor
8787
cp osx64/ruby-extractor ruby/tools/osx64/extractor

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ cargo build --release
1212

1313
## Generating the database schema and QL library
1414

15-
The generated `ruby.dbscheme` and `ruby_ast.qll` files are included in the repository, but they can be re-generated as follows:
15+
The generated `ql/src/ruby.dbscheme` and `ql/src/codeql_ruby/ast.qll` files are included in the repository, but they can be re-generated as follows:
1616

1717
```bash
1818
# Run the generator
1919
cargo run --release -p ruby-generator
2020
# Then auto-format the QL library
21-
codeql query format -i ruby_ast.qll
21+
codeql query format -i ql/src/codeql_ruby/ast.qll
2222
```

generator/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ fn main() {
286286
let ruby = Language {
287287
name: "Ruby".to_string(),
288288
node_types: tree_sitter_ruby::NODE_TYPES,
289-
dbscheme_path: PathBuf::from("ruby.dbscheme"),
290-
ql_library_path: PathBuf::from("ruby_ast.qll"),
289+
dbscheme_path: PathBuf::from("ql/src/ruby.dbscheme"),
290+
ql_library_path: PathBuf::from("ql/src/codeql_ruby/ast.qll"),
291291
};
292292
match node_types::read_node_types_str(&ruby.node_types) {
293293
Err(e) => {

ql/docs/experimental.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Experimental CodeQL queries and libraries
2+
3+
In addition to our standard CodeQL queries and libraries, this repository may also contain queries and libraries of a more experimental nature. Experimental queries and libraries can be improved incrementally and may eventually reach a sufficient maturity to be included in our standard libraries and queries.
4+
5+
Experimental queries and libraries may not be actively maintained as the standard libraries evolve. They may also be changed in backwards-incompatible ways or may be removed entirely in the future without deprecation warnings.
6+
7+
## Requirements
8+
9+
1. **Directory structure**
10+
11+
- Experimental queries and libraries are stored in the `ql/src/experimental` subdirectory, and any corresponding tests in `ql/test/experimental`.
12+
- The structure of an `experimental` subdirectory mirrors the structure of standard queries and libraries (or tests) in the parent directory.
13+
14+
2. **Query metadata**
15+
16+
- The query `@id` must not clash with any other queries in the repository.
17+
- The query must have a `@name` and `@description` to explain its purpose.
18+
- The query must have a `@kind` and `@problem.severity` as required by CodeQL tools.
19+
20+
For details, see the [guide on query metadata](https://github.com/github/codeql/blob/master/docs/query-metadata-style-guide.md).
21+
22+
3. **Formatting**
23+
24+
- The queries and libraries must be [autoformatted](https://help.semmle.com/codeql/codeql-for-vscode/reference/editor.html#autoformatting).
25+
26+
4. **Compilation**
27+
28+
- Compilation of the query and any associated libraries and tests must be resilient to future development of the standard libraries. This means that the functionality cannot use internal APIs, cannot depend on the output of `getAQlClass`, and cannot make use of regexp matching on `toString`.
29+
- The query and any associated libraries and tests must not cause any compiler warnings to be emitted (such as use of deprecated functionality or missing `override` annotations).
30+
31+
5. **Results**
32+
33+
- The query must have at least one true positive result on some revision of a real project.
34+
35+
## Non-requirements
36+
37+
Other criteria typically required for our standard queries and libraries are not required for experimental queries and libraries. In particular, fully disciplined query [metadata](https://github.com/github/codeql/blob/master/docs/query-metadata-style-guide.md), query [help](https://github.com/github/codeql/blob/master/docs/query-help-style-guide.md), tests, a low false positive rate and performance tuning are not required (but nonetheless recommended).

ql/examples/qlpack.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: codeql-ruby-examples
2+
version: 0.0.0
3+
libraryPathDependencies: codeql-ruby
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- description: Standard Code Scanning queries for Ruby
2+
- qlpack: codeql-ruby
3+
- apply: code-scanning-selectors.yml
4+
from: codeql-suite-helpers
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
- description: Standard LGTM queries for Ruby, including ones not displayed by default
2+
- qlpack: codeql-ruby
3+
- apply: lgtm-selectors.yml
4+
from: codeql-suite-helpers
5+
# These are only for IDE use.
6+
- exclude:
7+
tags contain:
8+
- ide-contextual-queries/local-definitions
9+
- ide-contextual-queries/local-references
10+
- query: Metrics/FLinesOfCode.ql
11+

ql/src/codeql-suites/ruby-lgtm.qls

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- description: Standard LGTM queries for Ruby
2+
- apply: codeql-suites/ruby-lgtm-full.qls
3+
- apply: lgtm-displayed-only.yml
4+
from: codeql-suite-helpers
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- description: Security-and-quality queries for Ruby
2+
- qlpack: codeql-ruby
3+
- apply: security-and-quality-selectors.yml
4+
from: codeql-suite-helpers
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- description: Security-extended queries for Ruby
2+
- qlpack: codeql-ruby
3+
- apply: security-extended-selectors.yml
4+
from: codeql-suite-helpers
File renamed without changes.

ql/src/experimental/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This directory contains [experimental](../../docs/experimental.md) CodeQL queries and libraries.

ql/src/qlpack.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: codeql-ruby
2+
version: 0.0.0
3+
dbscheme: ruby.dbscheme
4+
suites: codeql-suites
5+
extractor: ruby
File renamed without changes.

0 commit comments

Comments
 (0)