Skip to content

Commit 1d38ca3

Browse files
authored
Merge pull request github#15845 from github/tausbn/python-extractor-fix-build
Python: Build external extractor
2 parents 648543f + d12ac1e commit 1d38ca3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+280
-127
lines changed

codeql-workspace.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ provide:
66
- "*/ql/consistency-queries/qlpack.yml"
77
- "*/ql/automodel/src/qlpack.yml"
88
- "*/ql/automodel/test/qlpack.yml"
9+
- "python/extractor/qlpack.yml"
910
- "shared/**/qlpack.yml"
1011
- "cpp/ql/test/query-tests/Security/CWE/CWE-190/semmle/tainted/qlpack.yml"
1112
- "go/ql/config/legacy-support/qlpack.yml"

python/BUILD.bazel

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
load("@rules_pkg//:mappings.bzl", "pkg_filegroup", "pkg_files")
1+
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files")
2+
load("@semmle_code//:dist.bzl", "dist", "pack_zip")
3+
load("//:defs.bzl", "codeql_platform")
24

35
package(default_visibility = ["//visibility:public"])
46

@@ -28,3 +30,32 @@ pkg_filegroup(
2830
"//python/downgrades",
2931
],
3032
)
33+
34+
pkg_files(
35+
name = "codeql-extractor-yml",
36+
srcs = ["codeql-extractor.yml"],
37+
strip_prefix = None,
38+
)
39+
40+
dist(
41+
name = "extractor-generic",
42+
srcs = [
43+
":codeql-extractor-yml",
44+
":dbscheme-group",
45+
"//python/downgrades",
46+
"//python/extractor",
47+
"//python/tools",
48+
],
49+
prefix = "python",
50+
visibility = ["//visibility:public"],
51+
)
52+
53+
pack_zip(
54+
name = "extractor-arch",
55+
srcs = [
56+
"//python/extractor/tsg-python",
57+
],
58+
package_file_name = "extractor-" + codeql_platform + ".zip",
59+
prefix = "python/tools/" + codeql_platform,
60+
visibility = ["//visibility:public"],
61+
)

python/codeql-extractor.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: "python"
2+
display_name: "Python"
3+
version: 1.22.1
4+
column_kind: utf32
5+
build_modes:
6+
- none
7+
github_api_languages:
8+
- Python
9+
scc_languages:
10+
- Python
11+
file_types:
12+
- name: python
13+
display_name: Python sources
14+
extensions:
15+
- .py
16+
legacy_qltest_extraction: true
17+
options:
18+
logging:
19+
title: Options pertaining to logging.
20+
type: object
21+
properties:
22+
verbosity:
23+
title: Python extractor logging verbosity level.
24+
description: >
25+
Controls the level of verbosity of the CodeQL Python extractor.
26+
27+
The supported levels are (in order of increasing verbosity):
28+
29+
- off
30+
- errors
31+
- warnings
32+
- info or progress
33+
- debug or progress+
34+
- trace or progress++
35+
- progress+++
36+
type: string
37+
pattern: "^(off|errors|warnings|(info|progress)|(debug|progress\\+)|(trace|progress\\+\\+)|progress\\+\\+\\+)$"
38+
python_executable_name:
39+
title: Controls the name of the Python executable used by the Python extractor.
40+
description: >
41+
The Python extractor uses platform-dependent heuristics to determine the name of the Python executable to use.
42+
Specifying a value for this option overrides the name of the Python executable used by the extractor.
43+
Accepted values are py, python and python3.
44+
Use this setting with caution, the Python extractor requires Python 3 to run.
45+
type: string
46+
pattern: "^(py|python|python3)$"

python/extractor/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("//:dist.bzl", "pack_zip")
1+
load("@semmle_code//:dist.bzl", "pack_zip")
22

33
py_binary(
44
name = "make-zips-py",
@@ -33,7 +33,7 @@ genrule(
3333
)
3434

3535
pack_zip(
36-
name = "extractor-python",
36+
name = "extractor",
3737
srcs = [
3838
"LICENSE-PSF.md", # because we distribute imp.py
3939
"convert_setup.py",

python/extractor/cli-integration-test/writing-diagnostics/test_diagnostics_output.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import sys
3-
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "..", "integration-tests"))
3+
sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", "..", "integration-tests"))
44
import diagnostics_test_utils
55

66
test_db = "db"

python/extractor/qlpack.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: extractor-python
22
dependencies:
3-
codeql/python-all: "*"
4-
codeql/python-queries: "*"
3+
codeql/python-all: ${workspace}
4+
codeql/python-queries: ${workspace}
55
extractor: python
66
warnOnImplicitThis: true

python/extractor/tests/test_patterns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self, name):
1212

1313
def test(self):
1414
repo_dir = subprocess.Popen(["git", "rev-parse", "--show-toplevel"], stdout=subprocess.PIPE).communicate()[0].rstrip().decode("utf-8")
15-
test_file_path = os.path.abspath(os.path.join(repo_dir, "unit-tests", "files", "pattern-matching", "patterns.json"))
15+
test_file_path = os.path.abspath(os.path.join(repo_dir, "..", "unit-tests", "files", "pattern-matching", "patterns.json"))
1616
with open(test_file_path) as test_file:
1717
test_patterns = json.load(test_file)
1818
for test_pattern in test_patterns:

python/extractor/tsg-python/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("@tsg_python_crate_index//:defs.bzl", "aliases", "all_crate_deps")
2-
load("//:common.bzl", "codeql_rust_binary")
1+
load("@py_deps//:defs.bzl", "aliases", "all_crate_deps")
2+
load("@semmle_code//:common.bzl", "codeql_rust_binary")
33

44
codeql_rust_binary(
55
name = "tsg-python",
@@ -12,5 +12,5 @@ codeql_rust_binary(
1212
visibility = ["//visibility:public"],
1313
deps = all_crate_deps(
1414
normal = True,
15-
) + ["//extractor-python/tsg-python/tree-sitter-python"],
15+
) + ["//python/extractor/tsg-python/tsp"],
1616
)

0 commit comments

Comments
 (0)