Skip to content

Commit f5de2e6

Browse files
Merge pull request #262 from blacklanternsecurity/dev
Dev -> Stable 10.0.0
2 parents 1082467 + 5ff4043 commit f5de2e6

19 files changed

Lines changed: 145 additions & 33 deletions

.github/workflows/daily-update.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ jobs:
5757
run: |
5858
git config user.name "github-actions[bot]"
5959
git config user.email "github-actions[bot]@users.noreply.github.com"
60-
git add cloud_providers_v2.json README.md
60+
git add cloud_providers_v3.json README.md
6161
git commit -m "chore: daily signature update $(date -u +%Y-%m-%d)"
6262
git push origin HEAD:stable

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cloudcheck"
3-
version = "9.3.0"
3+
version = "10.0.0"
44
edition = "2024"
55
description = "CloudCheck is a simple Rust tool to check whether an IP address or hostname belongs to a cloud provider."
66
license = "GPL-3.0"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ CloudCheck is a simple Rust tool to check whether an IP address or hostname belo
2929

3030
## Cloud Provider Signatures
3131

32-
The latest cloud provider signatures are available in [`cloud_providers_v2.json`](https://github.com/blacklanternsecurity/cloudcheck/blob/master/cloud_providers_v2.json), which is updated daily via [CI/CD](.github/workflows/daily-update.yml). Domains associated with each cloud provider are fetched dynamically from the [v2fly community repository](https://github.com/v2fly/domain-list-community), and CIDRs are fetched from [ASNDB](https://asndb.api.bbot.io/).
32+
The latest cloud provider signatures are available in [`cloud_providers_v3.json`](https://github.com/blacklanternsecurity/cloudcheck/blob/master/cloud_providers_v3.json), which is updated daily via [CI/CD](.github/workflows/daily-update.yml). Domains associated with each cloud provider are fetched dynamically from the [v2fly community repository](https://github.com/v2fly/domain-list-community), and CIDRs are fetched from [ASNDB](https://asndb.api.bbot.io/).
3333

3434
Used by [BBOT](https://github.com/blacklanternsecurity/bbot) and [BBOT Server](https://github.com/blacklanternsecurity/bbot-server).
3535

cloudcheck/helpers.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import ipaddress
22
import os
3+
import sys
34
import httpx
45
from pathlib import Path
56
from typing import List, Set, Union
67

8+
_warned_missing_api_key = False
9+
710

811
def defrag_cidrs(
912
cidrs: List[Union[ipaddress.IPv4Network, ipaddress.IPv6Network]],
@@ -202,12 +205,22 @@ def strings_to_cidrs(
202205

203206

204207
def request(url, include_api_key=False, browser_headers=False, timeout=60, **kwargs):
208+
global _warned_missing_api_key
205209
headers = kwargs.get("headers", {})
206210
if browser_headers:
207211
headers.update(browser_base_headers)
208212
bbot_io_api_key = os.getenv("BBOT_IO_API_KEY")
209-
if include_api_key and bbot_io_api_key:
210-
headers["Authorization"] = f"Bearer {bbot_io_api_key}"
213+
if include_api_key:
214+
if bbot_io_api_key:
215+
headers["Authorization"] = f"Bearer {bbot_io_api_key}"
216+
elif not _warned_missing_api_key:
217+
_warned_missing_api_key = True
218+
print(
219+
"WARNING: BBOT_IO_API_KEY env var is not set; asndb requests will be "
220+
"unauthenticated and may be rate-limited. Export BBOT_IO_API_KEY before "
221+
"running the update.",
222+
file=sys.stderr,
223+
)
211224
kwargs["headers"] = headers
212225
kwargs["timeout"] = timeout
213226
kwargs.setdefault("follow_redirects", True)

cloudcheck/providers/amazon.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,21 @@ class Amazon(BaseProvider):
2525
]
2626
tags: List[str] = ["cloud"]
2727
_bucket_name_regex = r"[a-z0-9_][a-z0-9-\.]{1,61}[a-z0-9]"
28+
_region_regex = r"[a-z]{2}-[a-z]+-\d+"
2829
regexes: Dict[str, List[str]] = {
29-
"STORAGE_BUCKET_NAME": [_bucket_name_regex],
30+
"STORAGE_BUCKET_NAME": [r"(?P<name>" + _bucket_name_regex + r")"],
3031
"STORAGE_BUCKET_HOSTNAME": [
31-
r"(" + _bucket_name_regex + r")\.(s3-?(?:[a-z0-9-]*\.){1,2}amazonaws\.com)"
32+
r"(?P<name>" + _bucket_name_regex + r")\.s3\.amazonaws\.com",
33+
r"(?P<name>"
34+
+ _bucket_name_regex
35+
+ r")\.s3-(?P<region>"
36+
+ _region_regex
37+
+ r")\.amazonaws\.com",
38+
r"(?P<name>"
39+
+ _bucket_name_regex
40+
+ r")\.s3\.(?P<region>"
41+
+ _region_regex
42+
+ r")\.amazonaws\.com",
3243
],
3344
}
3445

cloudcheck/providers/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def __init__(self, **data):
6767
self._cache_dir = Path.home() / ".cache" / "cloudcheck"
6868
self._repo_url = "https://github.com/v2fly/domain-list-community.git"
6969
self._asndb_url = os.getenv("ASNDB_URL", "https://asndb.api.bbot.io/v1")
70-
self._bbot_io_api_key = os.getenv("BBOT_IO_API_KEY")
7170

7271
def update(self):
7372
print(f"Updating {self.name}")
@@ -184,6 +183,7 @@ def _fetch_org_id(self, org_id: str):
184183
print(f"Fetching {url}")
185184
res = self.request(url, include_api_key=True)
186185
print(f"{url} -> {res}: {res.text}")
186+
res.raise_for_status()
187187
j = res.json()
188188
return [a["asn"] for a in j.get("asns", [])], []
189189
except Exception as e:
@@ -242,6 +242,7 @@ def fetch_asn(
242242
try:
243243
res = self.request(url, include_api_key=True)
244244
print(f"{url} -> {res.text}")
245+
res.raise_for_status()
245246
j = res.json()
246247
cidrs = j.get("subnets", [])
247248
except Exception as e:

cloudcheck/providers/cloudflare.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ class Cloudflare(BaseProvider):
2323
]
2424
_bucket_name_regex = r"[a-z0-9_][a-z0-9-\.]{1,61}[a-z0-9]"
2525
regexes: Dict[str, List[str]] = {
26-
"STORAGE_BUCKET_NAME": [_bucket_name_regex],
26+
"STORAGE_BUCKET_NAME": [r"(?P<name>" + _bucket_name_regex + r")"],
2727
"STORAGE_BUCKET_HOSTNAME": [
28-
r"(" + _bucket_name_regex + r")\.(r2\.dev)",
29-
r"(" + _bucket_name_regex + r")\.(r2\.cloudflarestorage\.com)",
28+
r"(?P<name>" + _bucket_name_regex + r")\.r2\.dev",
29+
r"(?P<name>" + _bucket_name_regex + r")\.r2\.cloudflarestorage\.com",
3030
],
3131
}
3232

cloudcheck/providers/digitalocean.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ class DigitalOcean(BaseProvider):
1313
"DO-13-ARIN",
1414
]
1515
_bucket_name_regex = r"[a-z0-9][a-z0-9-]{2,62}"
16+
_region_regex = r"[a-z]{3}\d"
1617
regexes: Dict[str, List[str]] = {
17-
"STORAGE_BUCKET_NAME": [_bucket_name_regex],
18+
"STORAGE_BUCKET_NAME": [r"(?P<name>" + _bucket_name_regex + r")"],
1819
"STORAGE_BUCKET_HOSTNAME": [
19-
r"(" + _bucket_name_regex + r")\.([a-z]{3}[\d]{1}\.digitaloceanspaces\.com)"
20+
r"(?P<name>"
21+
+ _bucket_name_regex
22+
+ r")\.(?P<region>"
23+
+ _region_regex
24+
+ r")\.digitaloceanspaces\.com"
2025
],
2126
}
2227

cloudcheck/providers/gocache.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
class Gocache(BaseProvider):
66
tags: List[str] = ["cdn"]
77
short_description: str = "GoCache"
8-
long_description: str = "A Brazilian content delivery network provider offering CDN services."
8+
long_description: str = (
9+
"A Brazilian content delivery network provider offering CDN services."
10+
)
911

1012
_ips_url = "https://gocache.com.br/ips"
1113

0 commit comments

Comments
 (0)