Skip to content

Commit

Permalink
Correct index boundary issue for cpp.
Browse files Browse the repository at this point in the history
Signed-off-by: Caroline Russell <[email protected]>
  • Loading branch information
cerrussell committed Nov 28, 2024
1 parent b9e5f71 commit 945db9a
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions lib/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11641,7 +11641,7 @@ export function parseCmakeLikeFile(cmakeListFile, pkgType, options = {}) {
const pkgAddedMap = {};
const versionSpecifiersMap = {};
const versionsMap = {};
let parentComponent = {};
const parentComponent = {};
const templateValues = {};
cmakeListData = cmakeListData
.replace(/^ {2}/g, "")
Expand Down Expand Up @@ -11676,38 +11676,40 @@ export function parseCmakeLikeFile(cmakeListFile, pkgType, options = {}) {
const tmpB = (tmpA[1] || "")
.trim()
.replace(/["']/g, "")
.replace(/[ ]/g, ",")
.replace(/ +/g, ",")
.split(")")[0]
.split(",")
.filter((v) => v.length > 1);
const parentName = tmpB[0].replace(":", "");
let parentVersion = undefined;
.filter((v) => v.trim().length > 0);

const parentName = tmpB.length > 0 ? tmpB[0].replace(":", "").trim() : "";
let parentVersion;
// In case of meson.build we can find the version number after the word version
// thanks to our replaces and splits
const versionIndex = tmpB.findIndex((v) => v === "version");
if (versionIndex > -1 && tmpB.length > versionIndex) {
parentVersion = tmpB[versionIndex + 1];
const versionIndex = tmpB.findIndex((v) => v.trim() === "version");
if (versionIndex > -1 && versionIndex + 1 < tmpB.length) {
parentVersion = tmpB[versionIndex + 1].trim();
}
if (parentName?.length && !parentName.includes("$")) {
parentComponent = {
group: options.projectGroup || "",
if (parentName.length > 0 && !parentName.includes("$")) {
const parentComponent = {
group: options?.projectGroup || "",
name: parentName,
version: parentVersion || options.projectVersion || "",
type: "application",
version: parentVersion || options?.projectVersion || "",
type: "application"
};
parentComponent["purl"] = new PackageURL(
pkgType,
parentComponent.group,
parentComponent.name,
parentComponent.version,
null,
path,
path
).toString();
parentComponent["bom-ref"] = decodeURIComponent(
parentComponent["purl"],
parentComponent["purl"]
);
}
}

} else if (l.startsWith("find_")) {
let tmpA = [];
for (const fm of [
Expand Down

0 comments on commit 945db9a

Please sign in to comment.