diff options
author | Christian Cleberg <hello@cleberg.net> | 2025-04-07 22:52:59 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-07 22:52:59 -0500 |
commit | 8b78620c2c39c996007212616a586a8644ae7e33 (patch) | |
tree | 309e2dd196f9ce99893bf5f945dfcd8a8c0c3615 /applications/gitlab/branch_protections.py | |
parent | bee22b97b652cd04fa470d7f31c3b917e44f3ab9 (diff) | |
download | audit-tools-8b78620c2c39c996007212616a586a8644ae7e33.tar.gz audit-tools-8b78620c2c39c996007212616a586a8644ae7e33.tar.bz2 audit-tools-8b78620c2c39c996007212616a586a8644ae7e33.zip |
Gitlab enhancements (#2)
* add various in-progress scripts for gitlab
* Commit from GitHub Actions (Ruff)
* add gitlab results for free-tier tools
* Commit from GitHub Actions (Ruff)
* add gitlab results for ultimate-tier tools
* Commit from GitHub Actions (Ruff)
---------
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'applications/gitlab/branch_protections.py')
-rw-r--r-- | applications/gitlab/branch_protections.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/applications/gitlab/branch_protections.py b/applications/gitlab/branch_protections.py new file mode 100644 index 0000000..3d83165 --- /dev/null +++ b/applications/gitlab/branch_protections.py @@ -0,0 +1,25 @@ +"""
+List all branch protection rules and their configurations in GitLab.
+"""
+
+import requests
+import json
+
+BASE_URL = "https://gitlab.com/api/v4"
+PRIVATE_TOKEN = "your_access_token"
+PROJECT_ID = "your_project_id"
+TIMEOUT = 30
+
+URL = f"{BASE_URL}/projects/{PROJECT_ID}/protected_branches"
+HEADERS = {"PRIVATE-TOKEN": PRIVATE_TOKEN}
+
+if __name__ == "__main__":
+ # Get protected branches
+ response = requests.get(URL, headers=HEADERS, timeout=TIMEOUT)
+ if response.status_code == 200:
+ protected_branches = response.json()
+ print(json.dumps(protected_branches, indent=4))
+ else:
+ print(
+ f"Failed to fetch protected branches: {response.status_code}, {response.text}"
+ )
|