Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Governance] Code editor - add limitation for "NOT" logical operator #991

Merged
merged 5 commits into from
Nov 18, 2024
Merged
Changes from 1 commit
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
Next Next commit
Initial commit
JBakstPaloAlto committed Nov 17, 2024
commit baad1167b68b6c55638b52a47878daf0567c0216
Original file line number Diff line number Diff line change
@@ -6,7 +6,9 @@
Prisma Cloud supports Code Editor capability where you can create a policy rule for custom Configuration policies during Build-time checks. Code Editor is the default view for Build policy rule and as an example a YAML policy template is always available on the Prisma Cloud console.
The Code Editor is a suitable option when you want to create complex custom policies that include both Attribute and Connection-State with a support of AND/OR logic. However, for custom secrets Code Editor supports only an OR logic.

* *Attribute*
=== Key Features

==== Attribute-Based Policies
+
Attribute when defined in a policy describes attribute configurations for resources. Each resource must contain values the attribute configuration has specified or display the presence or absence of the attribute configuration. The syntax and attribute configurations used in YAML templates is similar to Terraform.
+
@@ -146,7 +148,7 @@ cond_type: "secrets"
- "my-super-secret-password-regex"
----

* *Connection State*
==== Connection-Based Policies
+
Connection State when defined in a policy specifies a connect or disconnect between resources of different types.
+
@@ -206,7 +208,7 @@ The table below provides instructions on how to use Connection State Operators.

|===

* *AND/OR Logic*
=== Logical (AND/OR) Operators
+
A policy may include layers of defined Attributes and Connection State, or both. To define the connection between the two AND/OR logic is used. Using Code Editor you can customize the Attribute, Connection State or both at multiple layers.
+
@@ -403,3 +405,20 @@ If there are errors in your custom code during a test, the console displays a so
//image::governance/code-editor-6.png
+
NOTE: You are in *Step 2* of Create Custom Policies for Build-Time Checks. You are required to complete the rest of the steps to see your new custom Build-time check policy on the Prisma Cloud console.

=== Limitation

Nesting``NOT` conditions within connection blocks is currently not supported.

EXAMPLE

----
definition:
not:
cond_type: "connection"
resource_types:
- "aws_elb"
connected_resource_types:
- "aws_security_group"
operator: "exists"
----

Unchanged files with check annotations Beta

}
batchPublish(process.argv.slice(2))
.then((results) => console.info(JSON.stringify(results, undefined, 2), `published ${results.length} docs`))

Check warning on line 95 in bin/batch-publish.js

GitHub Actions / build

Unexpected console statement
.catch(console.error);

Check warning on line 96 in bin/batch-publish.js

GitHub Actions / build

Unexpected console statement
const checkSitemapIndex = async () => {
const res = await fetch(`${ORIGIN}/sitemap-index.xml`);
if (!res.ok) {
console.error(`ERROR: Failed to fetch sitemap-index: ${res.status}`);

Check warning on line 21 in bin/check-sitemap-index.js

GitHub Actions / build

Unexpected console statement
process.exit(1);
}
const index = create(text).toObject();
if (!index.sitemapindex?.sitemap) {
console.error('ERROR: Invalid sitemap-index, unexpected structure');

Check warning on line 29 in bin/check-sitemap-index.js

GitHub Actions / build

Unexpected console statement
process.exit(1);
}
return;
}
if (typeof existingMaps[pathname] === 'undefined') {
console.warn(`WARNING: Sitemap exists in sitemap-index, but not in docs repository: ${pathname}`);

Check warning on line 52 in bin/check-sitemap-index.js

GitHub Actions / build

Unexpected console statement
}
existingMaps[pathname] = true;
}, {});
// eslint-disable-next-line no-unused-vars
const missing = Object.entries(existingMaps).filter(([_, v]) => !v).map(([k]) => k);
if (missing.length) {
console.error(`ERROR: ${missing.length} sitemap(s) missing from sitemap-index: \n\t- ${missing.join('\n\t- ')}`);

Check warning on line 60 in bin/check-sitemap-index.js

GitHub Actions / build

Unexpected console statement
process.exit(1);
}
};
checkSitemapIndex().catch(console.error);

Check warning on line 65 in bin/check-sitemap-index.js

GitHub Actions / build

Unexpected console statement
};
generateRedirects()
.then((count) => console.info(`[bin/generate-redirects] generated ${count} redirects`))

Check warning on line 128 in bin/generate-redirects.js

GitHub Actions / build

Unexpected console statement
.catch(console.error);

Check warning on line 129 in bin/generate-redirects.js

GitHub Actions / build

Unexpected console statement
try {
const stat = await fs.stat(adocPath);
if (!stat.isFile()) {
console.warn(`invalid adoc (directory), excluding from sitemap: ${adocPath}`);

Check warning on line 289 in bin/generate-sitemaps.js

GitHub Actions / build

Unexpected console statement
return;
}
} catch (e) {