FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql-python/codeql/common.py at master · balfroim/codeql-python · GitHub
balfroim
codeql-python
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql-python
/
codeql
/
common.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
57 lines (48 loc) · 1.24 KB
Breadcrumbs
codeql-python
/
codeql
/
common.py
Copy path
File metadata and controls
57 lines (48 loc) · 1.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
CodeQL for Python.
"""
import
os
import
subprocess
import
tempfile
import
uuid
# Configuration
codeql_path
=
'codeql'
search_path
=
None
library_path
=
None
# Temporaries
temp_path
=
None
def
temporary_root
():
global
temp_path
if
temp_path
is
None
:
temp_path
=
tempfile
.
TemporaryDirectory
(
prefix
=
"codeql-python_"
)
return
temp_path
.
name
def
temporary_path
(
prefix
,
suffix
):
name
=
''
if
prefix
:
name
+=
prefix
name
+=
uuid
.
uuid4
().
hex
if
suffix
:
name
+=
suffix
return
os
.
path
.
join
(
temporary_root
(),
name
)
def
temporary_dir
(
create
=
True
,
prefix
=
None
,
suffix
=
None
):
path
=
temporary_path
(
prefix
,
suffix
)
if
create
:
os
.
mkdir
(
path
)
return
path
def
temporary_file
(
create
=
True
,
prefix
=
None
,
suffix
=
None
):
path
=
temporary_path
(
prefix
,
suffix
)
if
create
:
open
(
path
,
'a'
).
close
()
return
path
# Environment
def
set_search_path
(
path
):
global
search_path
if
type
(
path
)
==
list
:
separator
=
';'
if
os
.
name
==
'nt'
else
':'
path
=
separator
.
join
(
path
)
search_path
=
path
def
run
(
args
):
command
=
[
codeql_path
]
+
list
(
map
(
str
,
args
))
return
subprocess
.
run
(
command
,
stdout
=
subprocess
.
DEVNULL
)
Back
|
FazBrowse Home
|
New Git URL