Skip to content

Commit e1f25e3

Browse files
fix(cloudflare): add the SSL and Certificates scope to the UI token links
The provider wizard builds its own copies of the two prefilled Cloudflare token URLs, so fixing the docs alone would leave anyone onboarding through the UI with the same incomplete token and the same false Universal SSL failure. Updates PRECONFIGURED_CREDENTIAL_URLS.CLOUDFLARE_API_TOKEN_USER and buildCloudflareAccountOwnedApiTokenUrl to request the fifth scope, along with the comments in both that enumerate the four, and the tests that pin the exact URL and the decoded permissionGroupKeys. The comments in external-urls.ts ask for these to be kept in sync with the docs; they now are.
1 parent 886fe7c commit e1f25e3

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

ui/components/providers/workflow/forms/select-credentials-type/cloudflare/credentials-type/cloudflare-api-token-credentials-form.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const Harness = ({ providerUid }: { providerUid?: string }) => {
2121
};
2222

2323
const USER_URL =
24-
"https://dash.cloudflare.com/profile/api-tokens?permissionGroupKeys=%5B%7B%22key%22%3A%22account_settings%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22zone%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22zone_settings%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22dns%22%2C%22type%22%3A%22read%22%7D%5D&accountId=%2A&zoneId=all&name=Prowler%20Security%20Scanner";
24+
"https://dash.cloudflare.com/profile/api-tokens?permissionGroupKeys=%5B%7B%22key%22%3A%22account_settings%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22zone%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22zone_settings%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22dns%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22ssl_and_certificates%22%2C%22type%22%3A%22read%22%7D%5D&accountId=%2A&zoneId=all&name=Prowler%20Security%20Scanner";
2525

2626
describe("CloudflareApiTokenCredentialsForm", () => {
2727
it("always renders the User API Token link with the correct href and safe target attributes", () => {

ui/lib/external-urls.test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,20 +114,21 @@ describe("getAWSOrgDeploymentQuickLink", () => {
114114
});
115115

116116
describe("PRECONFIGURED_CREDENTIAL_URLS", () => {
117-
it("keeps the Cloudflare User API Token URL under the profile route with the four required read scopes", () => {
117+
it("keeps the Cloudflare User API Token URL under the profile route with the five required read scopes", () => {
118118
// Snapshot check: fixes the exact URL so a stray edit to the permission
119119
// scopes, token name, account/zone selectors or console origin trips a
120120
// failing test instead of silently shipping a broken pre-configured
121121
// token flow to users. Matches the "User API Token" link in
122122
// docs/user-guide/providers/cloudflare/authentication.mdx.
123123
expect(PRECONFIGURED_CREDENTIAL_URLS.CLOUDFLARE_API_TOKEN_USER).toBe(
124-
"https://dash.cloudflare.com/profile/api-tokens?permissionGroupKeys=%5B%7B%22key%22%3A%22account_settings%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22zone%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22zone_settings%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22dns%22%2C%22type%22%3A%22read%22%7D%5D&accountId=%2A&zoneId=all&name=Prowler%20Security%20Scanner",
124+
"https://dash.cloudflare.com/profile/api-tokens?permissionGroupKeys=%5B%7B%22key%22%3A%22account_settings%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22zone%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22zone_settings%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22dns%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22ssl_and_certificates%22%2C%22type%22%3A%22read%22%7D%5D&accountId=%2A&zoneId=all&name=Prowler%20Security%20Scanner",
125125
);
126126
});
127127

128-
it("carries the four Prowler read scopes as decoded permissionGroupKeys on the Cloudflare User API Token URL", () => {
128+
it("carries the five Prowler read scopes as decoded permissionGroupKeys on the Cloudflare User API Token URL", () => {
129129
// Semantic contract: the URL must request read on account_settings, zone,
130-
// zone_settings and dns and reuse the shared Prowler token name.
130+
// zone_settings, dns and ssl_and_certificates and reuse the shared Prowler
131+
// token name.
131132
const parsed = new URL(
132133
PRECONFIGURED_CREDENTIAL_URLS.CLOUDFLARE_API_TOKEN_USER,
133134
);
@@ -140,6 +141,7 @@ describe("PRECONFIGURED_CREDENTIAL_URLS", () => {
140141
{ key: "zone", type: "read" },
141142
{ key: "zone_settings", type: "read" },
142143
{ key: "dns", type: "read" },
144+
{ key: "ssl_and_certificates", type: "read" },
143145
]);
144146
expect(parsed.searchParams.get("name")).toBe("Prowler Security Scanner");
145147
});
@@ -214,6 +216,7 @@ describe("buildCloudflareAccountOwnedApiTokenUrl", () => {
214216
{ key: "zone", type: "read" },
215217
{ key: "zone_settings", type: "read" },
216218
{ key: "dns", type: "read" },
219+
{ key: "ssl_and_certificates", type: "read" },
217220
]);
218221
});
219222

ui/lib/external-urls.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@ const CF_QUICKCREATE_BASE_URL =
6161
// `getAWSCredentialsTemplateLinks` below.
6262
export const PRECONFIGURED_CREDENTIAL_URLS = {
6363
// Opens the Cloudflare "Create Custom Token" form under the user profile
64-
// pre-filled with the four read-only scopes Prowler needs
65-
// (`Account Settings`, `Zone`, `Zone Settings`, `DNS`) and the token name.
64+
// pre-filled with the five read-only scopes Prowler needs
65+
// (`Account Settings`, `Zone`, `Zone Settings`, `DNS`, `SSL and Certificates`)
66+
// and the token name.
6667
// Kept in sync with the "User API Token" URL published in
6768
// docs/user-guide/providers/cloudflare/authentication.mdx.
6869
CLOUDFLARE_API_TOKEN_USER:
69-
"https://dash.cloudflare.com/profile/api-tokens?permissionGroupKeys=%5B%7B%22key%22%3A%22account_settings%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22zone%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22zone_settings%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22dns%22%2C%22type%22%3A%22read%22%7D%5D&accountId=%2A&zoneId=all&name=Prowler%20Security%20Scanner",
70+
"https://dash.cloudflare.com/profile/api-tokens?permissionGroupKeys=%5B%7B%22key%22%3A%22account_settings%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22zone%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22zone_settings%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22dns%22%2C%22type%22%3A%22read%22%7D%2C%7B%22key%22%3A%22ssl_and_certificates%22%2C%22type%22%3A%22read%22%7D%5D&accountId=%2A&zoneId=all&name=Prowler%20Security%20Scanner",
7071
// Opens the GitHub fine-grained PAT creation form pre-filled with the four
7172
// read-only permissions Prowler needs to scan a user's own repositories.
7273
// Kept in sync with the "user repositories" URL published in
@@ -82,7 +83,7 @@ export const PRECONFIGURED_CREDENTIAL_URLS = {
8283
// avoid ambiguity when the user is signed into multiple accounts. Navigating
8384
// directly to `/<accountId>/api-tokens/create` does NOT pre-fill the form —
8485
// Cloudflare only reads the pre-fill params when they arrive via the router.
85-
// Same four read-only scopes as the user token URL.
86+
// Same five read-only scopes as the user token URL.
8687
export const buildCloudflareAccountOwnedApiTokenUrl = (
8788
accountId: string,
8889
): string => {
@@ -97,6 +98,7 @@ export const buildCloudflareAccountOwnedApiTokenUrl = (
9798
{ key: "zone", type: "read" },
9899
{ key: "zone_settings", type: "read" },
99100
{ key: "dns", type: "read" },
101+
{ key: "ssl_and_certificates", type: "read" },
100102
]),
101103
);
102104
const name = encodeURIComponent("Prowler Security Scanner");

0 commit comments

Comments
 (0)