forked from TinderSec/gh-workflow-auditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
query_data.py
65 lines (64 loc) · 2.09 KB
/
query_data.py
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
58
59
60
61
62
63
64
65
def return_query(query_type,name,after=None):
if query_type == 'repository':
owner,name = name.split('/')
return f"""query {{
repository(owner: "{owner}",name: "{name}") {{
nameWithOwner
object(expression: "HEAD:.github/workflows/") {{
... on Tree {{
entries {{
name
lineCount
object {{
... on Blob {{
text
}}
}}
}}
}}
}}
}}
}}"""
else:
after_query = f",after:\"{after}\"" if after else ""
return f"""query {{
{query_type}(login:"{name}"){{
repositories(first:100 {after_query}){{
edges{{
node{{
nameWithOwner,
object(expression: "HEAD:.github/workflows/") {{
... on Tree {{
entries {{
name
lineCount
object {{
... on Blob {{
text
}}
}}
}}
}}
}}
}}
}}
pageInfo {{
startCursor
hasNextPage
endCursor
}}
}}
}}
}}"""
def validation_query(username, guess_type):
return f"""query {{
{guess_type}(login:"{username}"){{
repositories(first:1){{
edges{{
node{{
nameWithOwner
}}
}}
}}
}}
}}"""