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
53 changes: 30 additions & 23 deletions website/scripts/GenerateReleaseCatalogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ const CATALOGS_DIR = path.join(__dirname, '../../catalogs');
const OUTPUT_DIR = path.join(__dirname, '../src/data/ccc-releases');
const DELIVERY_TOOLKIT_DIR = path.join(__dirname, '../../delivery-toolkit');

/** Must all exist for generate-release-artifacts; partial dirs are skipped (matches delivery-toolkit loadCatalog). */
const REQUIRED_CATALOG_FILES = [
'metadata.yaml',
'controls.yaml',
'capabilities.yaml',
'threats.yaml',
] as const;

interface CatalogDirectory {
category: string;
service: string;
Expand Down Expand Up @@ -137,30 +145,29 @@ async function discoverCatalogDirectories(): Promise<CatalogDirectory[]> {
const releaseDetailsPath = path.join(servicePath, 'release-details.yaml');
const hasReleaseDetails = fs.existsSync(releaseDetailsPath);

// Check if this directory has the required catalog files (controls.yaml, capabilities.yaml, etc.)
const hasControls = fs.existsSync(path.join(servicePath, 'controls.yaml'));
const hasCapabilities = fs.existsSync(path.join(servicePath, 'capabilities.yaml'));
const hasThreats = fs.existsSync(path.join(servicePath, 'threats.yaml'));

// Only include directories that look like valid catalogs
const isValidCatalog = hasControls || hasCapabilities || hasThreats;

if (isValidCatalog) {
catalogs.push({
category,
service,
fullPath: servicePath,
hasReleaseDetails,
needsDevReleaseDetails: true // Always create DEV version
});

if (hasReleaseDetails) {
console.log(` ✅ Found with release details: ${category}/${service} (will also create DEV version)`);
} else {
console.log(` 🔧 Will create DEV version: ${category}/${service}`);
}
const missingRequired = REQUIRED_CATALOG_FILES.filter(
(f) => !fs.existsSync(path.join(servicePath, f))
);

if (missingRequired.length > 0) {
console.log(
` ⏭️ Skipping incomplete catalog: ${category}/${service} (missing: ${missingRequired.join(', ')})`
);
continue;
}

catalogs.push({
category,
service,
fullPath: servicePath,
hasReleaseDetails,
needsDevReleaseDetails: true // Always create DEV version
});

if (hasReleaseDetails) {
console.log(` ✅ Found with release details: ${category}/${service} (will also create DEV version)`);
} else {
console.log(` ⏭️ Skipping non-catalog: ${category}/${service}`);
console.log(` 🔧 Will create DEV version: ${category}/${service}`);
}
}
}
Expand Down
52 changes: 30 additions & 22 deletions website/src/components/ccc/Control/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import Layout from "@theme/Layout";
import Link from "@docusaurus/Link";
import useBrokenLinks from "@docusaurus/useBrokenLinks";
import { Card, CardContent, CardHeader, CardTitle } from "../../ui/card";
import { Badge } from "../../ui/badge";
import { ControlPageData } from "@site/src/types/ccc";
Expand All @@ -11,6 +12,7 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from ".

export default function CCCControlTemplate({ pageData }: { pageData: ControlPageData }) {
const { control, releaseTitle, releaseSlug, related_threats, related_capabilities } = pageData;
const brokenLinks = useBrokenLinks();

return (
<Layout title={control.title}>
Expand Down Expand Up @@ -65,28 +67,34 @@ export default function CCCControlTemplate({ pageData }: { pageData: ControlPage
</TableRow>
</TableHeader>
<TableBody>
{control.test_requirements.map((tr) => (
<TableRow key={tr.id}>
<TableCell className="font-mono font-medium">
<a id={tr.id.split(".").pop()?.toLowerCase()} className="anchor-target"></a>
{tr.id}
</TableCell>
<TableCell className="max-w-md">{tr.text}</TableCell>
<TableCell>
{tr.applicability?.length > 0 ? (
<div className="flex flex-wrap gap-1">
{tr.applicability.map((level) => (
<Badge key={level} variant="outline" className="bg-blue-100 text-blue-800 font-medium border border-blue-300 text-xs">
{level}
</Badge>
))}
</div>
) : (
<span className="text-muted-foreground">-</span>
)}
</TableCell>
</TableRow>
))}
{control.test_requirements.map((tr) => {
const anchorId = tr.id.split(".").pop()?.toLowerCase();
if (anchorId) {
brokenLinks.collectAnchor(anchorId);
}
return (
<TableRow key={tr.id}>
<TableCell className="font-mono font-medium">
<a id={anchorId} className="anchor-target"></a>
{tr.id}
</TableCell>
<TableCell className="max-w-md">{tr.text}</TableCell>
<TableCell>
{tr.applicability?.length > 0 ? (
<div className="flex flex-wrap gap-1">
{tr.applicability.map((level) => (
<Badge key={level} variant="outline" className="bg-blue-100 text-blue-800 font-medium border border-blue-300 text-xs">
{level}
</Badge>
))}
</div>
) : (
<span className="text-muted-foreground">-</span>
)}
</TableCell>
</TableRow>
);
})}
</TableBody>
</Table>
</CardContent>
Expand Down
Loading