Skip to content

Commit

Permalink
Fixes #1498. Don't remove await (#1509)
Browse files Browse the repository at this point in the history
* Fixes #1498. Don't remove await

Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>

* Tune partial check for cbom

Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>

---------

Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
  • Loading branch information
prabhu authored Dec 22, 2024
1 parent bc98665 commit 5e09a04
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
12 changes: 6 additions & 6 deletions lib/evinser/evinser.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export async function createSlice(
options = {},
) {
if (!filePath) {
return;
return undefined;
}
const firstLanguage = Array.isArray(purlOrLanguages)
? purlOrLanguages[0]
Expand All @@ -227,7 +227,7 @@ export async function createSlice(
PROJECT_TYPE_ALIASES.swift.includes(language) &&
sliceType !== "semantics"
) {
return;
return undefined;
}

let sliceOutputDir = fs.mkdtempSync(
Expand Down Expand Up @@ -388,7 +388,7 @@ export async function analyzeProject(dbObjMap, options) {
fs.readFileSync(options.reachablesSlicesFile, "utf-8"),
);
} else {
retMap = createSlice(language, dirPath, "reachables", options);
retMap = await createSlice(language, dirPath, "reachables", options);
if (retMap?.slicesFile && fs.existsSync(retMap.slicesFile)) {
reachablesSlicesFile = retMap.slicesFile;
reachablesSlice = JSON.parse(
Expand All @@ -409,7 +409,7 @@ export async function analyzeProject(dbObjMap, options) {
usagesSlicesFile = options.usagesSlicesFile;
} else {
// Generate our own slices
retMap = createSlice(language, dirPath, "usages", options);
retMap = await createSlice(language, dirPath, "usages", options);
if (retMap?.slicesFile && fs.existsSync(retMap.slicesFile)) {
usageSlice = JSON.parse(fs.readFileSync(retMap.slicesFile, "utf-8"));
usagesSlicesFile = retMap.slicesFile;
Expand All @@ -428,7 +428,7 @@ export async function analyzeProject(dbObjMap, options) {
semanticsSlicesFile = options.semanticsSlicesFile;
} else {
// Generate our own slices
retMap = createSlice(language, dirPath, "semantics", options);
retMap = await createSlice(language, dirPath, "semantics", options);
if (retMap?.slicesFile && fs.existsSync(retMap.slicesFile)) {
semanticsSlice = JSON.parse(
fs.readFileSync(retMap.slicesFile, "utf-8"),
Expand Down Expand Up @@ -471,7 +471,7 @@ export async function analyzeProject(dbObjMap, options) {
fs.readFileSync(options.dataFlowSlicesFile, "utf-8"),
);
} else {
retMap = createSlice(language, dirPath, "data-flow", options);
retMap = await createSlice(language, dirPath, "data-flow", options);
if (retMap?.slicesFile && fs.existsSync(retMap.slicesFile)) {
dataFlowSlicesFile = retMap.slicesFile;
dataFlowSlice = JSON.parse(fs.readFileSync(retMap.slicesFile, "utf-8"));
Expand Down
7 changes: 6 additions & 1 deletion lib/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12792,15 +12792,20 @@ export function isPartialTree(dependencies, componentsCount = 1) {
if (dependencies?.length <= 1) {
return true;
}
let isCbom = false;
let parentsWithChildsCount = 0;
for (const adep of dependencies) {
if (adep?.dependsOn.length > 0) {
parentsWithChildsCount++;
}
if (!isCbom && adep?.provides?.length > 0) {
isCbom = true;
}
}
return (
!isCbom &&
parentsWithChildsCount <
Math.min(Math.round(componentsCount / 3), componentsCount)
Math.min(Math.round(componentsCount / 3), componentsCount)
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/helpers/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export const validateRefs = (bomJson) => {
if (bomJson?.dependencies) {
if (isPartialTree(bomJson.dependencies, bomJson?.components?.length)) {
warningsList.push(
"Dependency tree is partial with multiple empty dependsOn attributes.",
"Dependency tree has multiple empty dependsOn attributes.",
);
}
for (const dep of bomJson.dependencies) {
Expand Down
2 changes: 1 addition & 1 deletion types/lib/helpers/utils.d.ts.map

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

0 comments on commit 5e09a04

Please sign in to comment.