Skip to content

Commit 9b469d7

Browse files
authored
Merge pull request XmirrorSecurity#279 from luotianqi777/gitee_scan
feat: update
2 parents 38b8f4e + f688486 commit 9b469d7

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

scripts/gitlab_scan.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def scan_gitlab(
121121
gitlab_args: gitlab client args
122122
"""
123123

124-
# config gitlab auth
124+
# config gitlab
125125
gl = gitlab.Gitlab(
126126
url=gitlab_url,
127127
private_token=gitlab_token,
@@ -132,25 +132,27 @@ def scan_gitlab(
132132
# foreach repo
133133
s = OpenscaGitlabScanner(cli, gl)
134134
for repo, branches in s.projects().items():
135+
pid = str(repo.get_id())
136+
repo_dir = os.path.join(download_dir, pid)
137+
output_dir = os.path.join(report_dir, pid)
138+
mkdirs(output_dir)
135139
# foreach repo branch
136140
for branch in branches:
137-
pid = str(repo.get_id())
138141
bid = str(branch.get_id())
139-
repo_dir = os.path.join(download_dir, pid)
140142
branch_dir = os.path.join(repo_dir, bid)
141-
output_dir = os.path.join(report_dir, pid)
142143
output_files = [os.path.join(output_dir, bid + ext) for ext in report_ext]
143144
output_log = os.path.join(output_dir, bid + ".opensca.log")
144145
mkdirs(branch_dir)
145-
mkdirs(output_dir)
146146
# download repo branch
147147
print(f"download repo:{pid} branch:{bid}")
148148
s.download(repo, branch, branch_dir)
149149
# scan repo branch
150150
print(f"scan repo:{pid} branch:{bid}")
151151
s.scan(branch_dir, ",".join(output_files), output_log)
152-
# delete download repo
153-
shutil.rmtree(repo_dir)
152+
# delete download branch
153+
shutil.rmtree(branch_dir)
154+
# delete download repo
155+
shutil.rmtree(repo_dir)
154156

155157

156158
if __name__ == "__main__":

0 commit comments

Comments
 (0)