security: encode request parameters, enforce HTTPS, add timeouts (#2)
- query values (zone names, subdomains) are URL-encoded, zone and record IDs must be alphanumeric: prevents query parameter injection and path traversal - zone names and subdomains with whitespace, control characters or \ ? # & ; | < > " ' ` are rejected with an IllegalArgumentException - withBaseUrl only accepts HTTPS (plain HTTP only for loopback hosts), no query/fragment, trailing slash is removed - connect and response timeouts (defaults 10 s / 30 s), configurable via withConnectTimeout / withResponseTimeout; values below 1 ms or overflowing milliseconds are rejected - null credentials throw an IllegalArgumentException, build() without authentication an IllegalStateException - tests, README and changelog updated refs #2 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f6c0544d9a
commit
c7f27f2ac0
10 files changed
+441
-38
No files matched your search
@@ -62,6 +62,19 @@ CfDnsClient cfDnsClient = new CfDnsClientBuilder()
|
||||
.build();
|
||||
```
|
||||
|
||||
#### Further options:
|
||||
```java
|
||||
CfDnsClient cfDnsClient = new CfDnsClientBuilder()
|
||||
.withApiTokenAuth("your-api-token")
|
||||
.withBaseUrl("https://custom-api.example.com/client/v4") // must use HTTPS
|
||||
.withConnectTimeout(Duration.ofSeconds(5)) // default: 10 s
|
||||
.withResponseTimeout(Duration.ofSeconds(15)) // default: 30 s
|
||||
.withEmptyResultThrowsException(true) // default: false
|
||||
.build();
|
||||
```
|
||||
|
||||
`build()` throws an `IllegalStateException` if no authentication is configured.
|
||||
|
||||
The client is thread-safe and should be reused, it holds a pool of HTTP connections.
|
||||
`CfDnsClient` implements `AutoCloseable`, call `close()` (or use try-with-resources) to release the connections:
|
||||
|
||||
|
||||
Reference in new issue
Block a user