我正在尝试运行这个由 trufflehog 制作的 python 脚本,以使用他们的开源扫描程序一次扫描一个帐户或组织的所有 repo。
有谁知道我如何将我的组织名称和访问令牌放入 url 而不会弄乱其余部分?
def get_org_repos(orgname, page):
response = requests.get(url='https://api.github.com/users/' + orgname + '/repos?page={}'.format(page))
json = response.json()
if not json:
return None
for item in json:
if item['fork'] == False:
print('searching ' + item["html_url"])
results = truffleHog.find_strings(item["html_url"], do_regex=True, custom_regexes=rules, do_entropy=False, max_depth=100000)
for issue in results["foundIssues"]:
d = loads(open(issue).read())
d['github_url'] = "{}/blob/{}/{}".format(item["html_url"], d['commitHash'], d['path'])
d['github_commit_url'] = "{}/commit/{}".format(item["html_url"], d['commitHash'])
d['diff'] = d['diff'][0:200]
d['printDiff'] = d['printDiff'][0:200]
print(dumps(d, indent=4))
get_org_repos(orgname, page + 1)
get_org_repos("insertOrgName", 1)
到目前为止,我已经尝试了一些变化,比如
requests.get(url='https://api.github.com/users/myOrg/repos?access_token=xyz?page={}'.format(page))