Skip to content

Commit

Permalink
First cut for automatic annotations and tagging
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
  • Loading branch information
prabhu committed Nov 11, 2024
1 parent 16a4907 commit f48a806
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
13 changes: 11 additions & 2 deletions lib/stages/postgen/postgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,18 +287,24 @@ export function cleanupEnv(_options) {
* Annotate the document with annotator
*
* @param {Object} bomJson BOM JSON Object
* @param {Object} _options CLI options
* @param {Object} options CLI options
*
* @returns {Object} Annotated BOM JSON
*/
export function annotate(bomJson, _options) {
export function annotate(bomJson, options) {
if (!bomJson?.components) {
return bomJson;
}
const bomAnnotations = bomJson.annotations || [];
const cdxgenAnnotator = bomJson.metadata.tools.components.filter(
(c) => c.name === "cdxgen",
);
if (!cdxgenAnnotator.length) {
return bomJson;
}
const requiresContextTrimming = ["machine-learning", "ml"].includes(
options?.profile,
);
const metadataAnnotations = textualMetadata(bomJson);
if (metadataAnnotations && bomJson.metadata?.component?.["bom-ref"]) {
bomAnnotations.push({
Expand All @@ -318,6 +324,9 @@ export function annotate(bomJson, _options) {
if (tags?.length) {
comp.tags = tags;
}
if (requiresContextTrimming) {
comp.properties = undefined;
}
}
return bomJson;
}
4 changes: 2 additions & 2 deletions types/lib/stages/postgen/postgen.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export function cleanupEnv(_options: any): void;
* Annotate the document with annotator
*
* @param {Object} bomJson BOM JSON Object
* @param {Object} _options CLI options
* @param {Object} options CLI options
*
* @returns {Object} Annotated BOM JSON
*/
export function annotate(bomJson: any, _options: any): any;
export function annotate(bomJson: any, options: any): any;
//# sourceMappingURL=postgen.d.ts.map
2 changes: 1 addition & 1 deletion types/lib/stages/postgen/postgen.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f48a806

Please sign in to comment.