Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import starlightLinksValidator from "starlight-links-validator";
import icon from "astro-icon";
import sitemap from "@astrojs/sitemap";
import react from "@astrojs/react";

import { readdir } from "fs/promises";
import { fileURLToPath } from "url";

import rehypeTitleFigure from "rehype-title-figure";
import rehypeMermaid from "./src/plugins/rehype/mermaid.ts";
import rehypeAutolinkHeadings from "./src/plugins/rehype/autolink-headings.ts";
import rehypeExternalLinks from "./src/plugins/rehype/external-links.ts";
import rehypeHeadingSlugs from "./src/plugins/rehype/heading-slugs.ts";
import { fileURLToPath } from "url";

async function autogenSections() {
const sections = (
Expand Down
42 changes: 31 additions & 11 deletions src/components/Render.astro
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,49 @@ const props = z.object({
let { file, product, params } = props.parse(Astro.props);
if (!product) {
product = Astro.params.slug?.split("/")[0];
}
const fromSlug = Astro.params.slug?.split("/")[0];
if (!product) {
throw new Error(
`[Render] Unable to infer which folder ${file} is in, please provide a "product" input with your "file" input.`,
);
if (!fromSlug) {
throw new Error(
`[Render] Unable to infer which folder ${file} is in, please provide a "product" input with your "file" input.`,
);
}
product = fromSlug;
}
const partial = await getEntry("partials", `${product}/${file}`);
const id = `${product}/${file}`;
const partial = await getEntry("partials", id);
if (!partial) {
throw new Error(
`[Render] Couldn't find partial: ${file}. Included on ${Astro.params.slug}`,
`[Render] Couldn't find "${id}" included on "${Astro.url.pathname}"`,
);
}
// We currently only enforce parameters if `params` is set in the frontmatter,
// until we can migrate existing `inputParameters` frontmatter to `params`.
if (partial.data.params) {
const expected = partial.data.params;
if (!params)
const expected = partial.data.params.sort();
const optional = expected.filter((p) => p.endsWith("?"));
const received = Object.keys(params ?? {}).sort();
const maximum = expected.length;
const minimum = maximum - optional.length;
if (
received.length < minimum ||
received.length > maximum ||
expected.some((p: string) => {
if (p.endsWith("?")) return false;
return !received.includes(p);
})
) {
throw new Error(
`${file} included on ${Astro.params.slug} expected parameters: ${expected}, got none`,
`[Render] Expected parameters ${JSON.stringify(expected)} but received parameters ${JSON.stringify(received)} for "${file}" included on "${Astro.url.pathname}"`,
);
}
}
const { Content } = await render(partial);
Expand Down
9 changes: 3 additions & 6 deletions src/content.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { z, defineCollection } from "astro:content";
import { defineCollection } from "astro:content";

import { docsLoader, i18nLoader } from "@astrojs/starlight/loaders";
import { docsSchema, i18nSchema } from "@astrojs/starlight/schema";
Expand All @@ -20,6 +20,7 @@ import {
warpReleasesSchema,
releaseNotesSchema,
fieldsSchema,
partialsSchema,
} from "~/schemas";

function contentLoader(name: string) {
Expand All @@ -36,10 +37,6 @@ function dataLoader(name: string) {
});
}

const partialSchema = z.object({
params: z.string().array().optional(),
});

export const collections = {
docs: defineCollection({
loader: docsLoader(),
Expand All @@ -61,7 +58,7 @@ export const collections = {
}),
partials: defineCollection({
loader: contentLoader("partials"),
schema: partialSchema,
schema: partialsSchema,
}),
glossary: defineCollection({
loader: dataLoader("glossary"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { Render } from "~/components";
<Render
file="casb/integration-description"
params={{
one: "Atlassian Confluence",
two: "Atlassian Confluence Cloud account",
integrationName: "Atlassian Confluence",
integrationAccountType: "Atlassian Confluence Cloud account",
}}
/>

Expand Down Expand Up @@ -43,7 +43,7 @@ These permissions follow the principle of least privilege to ensure that only th

<Render
file="casb/security-findings"
params={{ one: "Atlassian Confluence", two: "atlassian-confluence" }}
params={{ integrationName: "Atlassian Confluence", slugRelativePath: "atlassian-confluence" }}
/>

### Access security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Render } from "~/components";

<Render
file="casb/integration-description"
params={{ one: "Atlassian Jira", two: "Atlassian Jira Cloud account" }}
params={{ integrationName: "Atlassian Jira", integrationAccountType: "Atlassian Jira Cloud account" }}
/>

:::note
Expand All @@ -35,7 +35,7 @@ These permissions follow the principle of least privilege to ensure that only th

<Render
file="casb/security-findings"
params={{ one: "Jira Cloud", two: "atlassian-jira" }}
params={{ integrationName: "Jira Cloud", slugRelativePath: "atlassian-jira" }}
/>

### Access security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Render } from "~/components";

<Render
file="casb/integration-description"
params={{ one: "Amazon Web Services (AWS) S3", two: "AWS account" }}
params={{ integrationName: "Amazon Web Services (AWS) S3", integrationAccountType: "AWS account" }}
/>

## Integration prerequisites
Expand Down Expand Up @@ -65,7 +65,7 @@ For more information, refer to [Content findings](/cloudflare-one/applications/c

<Render
file="casb/security-findings"
params={{ one: "AWS S3", two: "aws-s3" }}
params={{ integrationName: "AWS S3", slugRelativePath: "aws-s3" }}
/>

### S3 Bucket security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Render } from "~/components";

<Render
file="casb/integration-description"
params={{ one: "Bitbucket Cloud", two: "Bitbucket Cloud Cloud account" }}
params={{ integrationName: "Bitbucket Cloud", integrationAccountType: "Bitbucket Cloud Cloud account" }}
/>

:::note
Expand Down Expand Up @@ -46,7 +46,7 @@ These permissions follow the principle of least privilege to ensure that only th

<Render
file="casb/security-findings"
params={{ one: "Bitbucket Cloud", two: "bitbucket-cloud" }}
params={{ integrationName: "Bitbucket Cloud", slugRelativePath: "bitbucket-cloud" }}
/>

### Repository security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Render } from "~/components";

<Render
file="casb/integration-description"
params={{ one: "Box", two: "Box account" }}
params={{ integrationName: "Box", integrationAccountType: "Box account" }}
/>

## Integration prerequisites
Expand All @@ -27,7 +27,7 @@ These permissions follow the principle of least privilege to ensure that only th

## Security findings

<Render file="casb/security-findings" params={{ one: "Box", two: "box" }} />
<Render file="casb/security-findings" params={{ integrationName: "Box", slugRelativePath: "box" }} />

### File sharing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Render } from "~/components";

<Render
file="casb/integration-description"
params={{ one: "Dropbox", two: "Dropbox account" }}
params={{ integrationName: "Dropbox", integrationAccountType: "Dropbox account" }}
/>

## Integration prerequisites
Expand Down Expand Up @@ -39,7 +39,7 @@ These permissions follow the principle of least privilege to ensure that only th

<Render
file="casb/security-findings"
params={{ one: "Dropbox", two: "dropbox" }}
params={{ integrationName: "Dropbox", slugRelativePath: "dropbox" }}
/>

### File and folder sharing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Render } from "~/components";

<Render
file="casb/integration-description"
params={{ one: "GitHub", two: "GitHub Organization" }}
params={{ integrationName: "GitHub", integrationAccountType: "GitHub Organization" }}
/>

## Integration prerequisites
Expand All @@ -36,7 +36,7 @@ These permissions follow the principle of least privilege to ensure that only th

<Render
file="casb/security-findings"
params={{ one: "GitHub", two: "github" }}
params={{ integrationName: "GitHub", slugRelativePath: "github" }}
/>

### Branches and merges
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Render } from "~/components";

<Render
file="casb/integration-description"
params={{ one: "Gmail", two: "Google Workspace account" }}
params={{ integrationName: "Gmail", integrationAccountType: "Google Workspace account" }}
/>

## Integration prerequisites
Expand All @@ -21,14 +21,14 @@ import { Render } from "~/components";

<Render
file="casb/integration-perms"
params={{ one: "Google Workspace", two: "google-workspace" }}
params={{ parentIntegration: "Google Workspace", parentSlug: "google-workspace" }}
/>

## Security findings

<Render
file="casb/security-findings"
params={{ one: "Gmail", two: "google-workspace/gmail" }}
params={{ integrationName: "Gmail", slugRelativePath: "google-workspace/gmail" }}
/>

### Gmail administrator settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Render } from "~/components";

<Render
file="casb/integration-description"
params={{ one: "Google Admin", two: "Google Workspace account" }}
params={{ integrationName: "Google Admin", integrationAccountType: "Google Workspace account" }}
/>

## Integration prerequisites
Expand All @@ -19,14 +19,14 @@ import { Render } from "~/components";

<Render
file="casb/integration-perms"
params={{ one: "Google Workspace", two: "google-workspace" }}
params={{ parentIntegration: "Google Workspace", parentSlug: "google-workspace" }}
/>

## Security findings

<Render
file="casb/security-findings"
params={{ one: "Google Admin", two: "google-workspace/google-admin" }}
params={{ integrationName: "Google Admin", slugRelativePath: "google-workspace/google-admin" }}
/>

### User account settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Render } from "~/components";

<Render
file="casb/integration-description"
params={{ one: "Google Calendar", two: "Google Workspace account" }}
params={{ integrationName: "Google Calendar", integrationAccountType: "Google Workspace account" }}
/>

## Integration prerequisites
Expand All @@ -19,14 +19,14 @@ import { Render } from "~/components";

<Render
file="casb/integration-perms"
params={{ one: "Google Workspace", two: "google-workspace" }}
params={{ parentIntegration: "Google Workspace", parentSlug: "google-workspace" }}
/>

## Security findings

<Render
file="casb/security-findings"
params={{ one: "Google Calendar", two: "google-workspace/google-calendar" }}
params={{ integrationName: "Google Calendar", slugRelativePath: "google-workspace/google-calendar" }}
/>

### Calendar sharing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Render } from "~/components";

<Render
file="casb/integration-description"
params={{ one: "Google Drive", two: "Google Workspace account" }}
params={{ integrationName: "Google Drive", integrationAccountType: "Google Workspace account" }}
/>

## Integration prerequisites
Expand All @@ -21,14 +21,14 @@ import { Render } from "~/components";

<Render
file="casb/integration-perms"
params={{ one: "Google Workspace", two: "google-workspace" }}
params={{ parentIntegration: "Google Workspace", parentSlug: "google-workspace" }}
/>

## Security findings

<Render
file="casb/security-findings"
params={{ one: "Google Drive", two: "google-workspace/google-drive" }}
params={{ integrationName: "Google Drive", slugRelativePath: "google-workspace/google-drive" }}
/>

### File sharing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { DirectoryListing, Render } from "~/components";

<Render
file="casb/integration-description"
params={{ one: "Google Workspace", two: "Google Workspace account" }}
params={{ integrationName: "Google Workspace", integrationAccountType: "Google Workspace account" }}
/>

This integration covers the following Google Workspace products:
Expand Down Expand Up @@ -40,7 +40,7 @@ These permissions follow the principle of least privilege to ensure that only th

<Render
file="casb/security-findings"
params={{ one: "Google Workspace", two: "google-workspace" }}
params={{ integrationName: "Google Workspace", slugRelativePath: "google-workspace" }}
/>

### User account settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { GlossaryTooltip, Render } from "~/components";

<Render
file="casb/integration-description"
params={{ one: "Admin Center", two: "Microsoft 365 account" }}
params={{ integrationName: "Admin Center", integrationAccountType: "Microsoft 365 account" }}
/>

## Integration prerequisites
Expand All @@ -21,14 +21,14 @@ import { GlossaryTooltip, Render } from "~/components";

<Render
file="casb/integration-perms"
params={{ one: "Microsoft 365", two: "microsoft-365" }}
params={{ parentIntegration: "Microsoft 365", parentSlug: "microsoft-365" }}
/>

## Security findings

<Render
file="casb/security-findings"
params={{ one: "Admin Center", two: "microsoft-365/admin-center" }}
params={{ integrationName: "Admin Center", slugRelativePath: "microsoft-365/admin-center" }}
/>

### User account settings
Expand Down
Loading