@codacy/tools-flawfinder-2 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +27 -53
- package/dist/metadata.d.ts +13 -0
- package/dist/metadata.js +39 -0
- package/package.json +13 -3
package/dist/index.js
CHANGED
|
@@ -38,7 +38,6 @@ var import_tooling2 = require("@codacy/tooling");
|
|
|
38
38
|
// src/adapter.ts
|
|
39
39
|
var import_tooling = require("@codacy/tooling");
|
|
40
40
|
var import_path = __toESM(require("path"));
|
|
41
|
-
var import_promises = __toESM(require("fs/promises"));
|
|
42
41
|
|
|
43
42
|
// src/patterns.json
|
|
44
43
|
var patterns_default = [
|
|
@@ -1820,6 +1819,18 @@ var patterns_default = [
|
|
|
1820
1819
|
}
|
|
1821
1820
|
];
|
|
1822
1821
|
|
|
1822
|
+
// src/metadata.ts
|
|
1823
|
+
var descriptor = {
|
|
1824
|
+
id: "flawfinder",
|
|
1825
|
+
displayName: "Flawfinder",
|
|
1826
|
+
preferredVersion: "2.0.19",
|
|
1827
|
+
languages: ["C", "CPP"],
|
|
1828
|
+
filePatterns: ["**/*.c", "**/*.h", "**/*.cpp", "**/*.cc", "**/*.cxx", "**/*.hpp"],
|
|
1829
|
+
supportedOS: ["linux", "darwin"],
|
|
1830
|
+
supportedArch: ["x64", "arm64"],
|
|
1831
|
+
supportedRunners: ["local", "container"]
|
|
1832
|
+
};
|
|
1833
|
+
|
|
1823
1834
|
// src/adapter.ts
|
|
1824
1835
|
var TOOL_ID = "flawfinder";
|
|
1825
1836
|
var PIP_PACKAGE = "flawfinder==2.0.19";
|
|
@@ -1841,37 +1852,6 @@ function extractFunctionName(ruleName) {
|
|
|
1841
1852
|
const slashIdx = ruleName.lastIndexOf("/");
|
|
1842
1853
|
return slashIdx >= 0 ? ruleName.slice(slashIdx + 1) : ruleName;
|
|
1843
1854
|
}
|
|
1844
|
-
function getLineContent(lines, lineNumber) {
|
|
1845
|
-
return lines[lineNumber - 1] ?? "";
|
|
1846
|
-
}
|
|
1847
|
-
async function readFileLines(filePath) {
|
|
1848
|
-
try {
|
|
1849
|
-
const content = await import_promises.default.readFile(filePath, "utf-8");
|
|
1850
|
-
return content.split("\n");
|
|
1851
|
-
} catch {
|
|
1852
|
-
return [];
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
function buildResult(startedAt, completedAt, issues, errors, filesAnalyzed) {
|
|
1856
|
-
const durationMs = completedAt.getTime() - startedAt.getTime();
|
|
1857
|
-
return {
|
|
1858
|
-
metadata: {
|
|
1859
|
-
startedAt: startedAt.toISOString(),
|
|
1860
|
-
completedAt: completedAt.toISOString(),
|
|
1861
|
-
durationMs
|
|
1862
|
-
},
|
|
1863
|
-
issues,
|
|
1864
|
-
errors,
|
|
1865
|
-
summary: {
|
|
1866
|
-
toolId: TOOL_ID,
|
|
1867
|
-
status: errors.some((e) => e.level === "error") ? "partial" : "success",
|
|
1868
|
-
issueCount: issues.length,
|
|
1869
|
-
errorCount: errors.length,
|
|
1870
|
-
durationMs,
|
|
1871
|
-
filesAnalyzed
|
|
1872
|
-
}
|
|
1873
|
-
};
|
|
1874
|
-
}
|
|
1875
1855
|
async function getVersionFromBinary(binaryPath) {
|
|
1876
1856
|
try {
|
|
1877
1857
|
const { stdout, stderr, exitCode } = await (0, import_tooling.spawnTool)(binaryPath, ["--version"], {
|
|
@@ -1893,16 +1873,9 @@ async function resolveBinaryPath(ctx) {
|
|
|
1893
1873
|
return BINARY;
|
|
1894
1874
|
}
|
|
1895
1875
|
var adapter = {
|
|
1896
|
-
|
|
1897
|
-
displayName: "Flawfinder",
|
|
1898
|
-
preferredVersion: "2.0.19",
|
|
1876
|
+
...descriptor,
|
|
1899
1877
|
compatibleVersions: ">=2.0.0",
|
|
1900
1878
|
website: "https://dwheeler.com/flawfinder/",
|
|
1901
|
-
languages: ["C", "CPP"],
|
|
1902
|
-
filePatterns: ["**/*.c", "**/*.h", "**/*.cpp", "**/*.cc", "**/*.cxx", "**/*.hpp"],
|
|
1903
|
-
supportedOS: ["linux", "darwin"],
|
|
1904
|
-
supportedArch: ["x64", "arm64"],
|
|
1905
|
-
supportedRunners: ["local", "container"],
|
|
1906
1879
|
prerequisites: [
|
|
1907
1880
|
{
|
|
1908
1881
|
name: "Python",
|
|
@@ -2065,13 +2038,7 @@ var adapter = {
|
|
|
2065
2038
|
const issues = [];
|
|
2066
2039
|
const errors = [];
|
|
2067
2040
|
if (ctx.targetFiles.length === 0) {
|
|
2068
|
-
return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, 0);
|
|
2069
|
-
}
|
|
2070
|
-
if (!(codacyConfig.useLocalConfigurationFile && codacyConfig.localConfigurationFile) && codacyConfig.patterns.length === 0) {
|
|
2071
|
-
ctx.logger.info("Skipping analysis: no local config and no patterns enabled", {
|
|
2072
|
-
toolId: TOOL_ID
|
|
2073
|
-
});
|
|
2074
|
-
return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
2041
|
+
return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, 0);
|
|
2075
2042
|
}
|
|
2076
2043
|
const binary = await resolveBinaryPath(ctx);
|
|
2077
2044
|
const absoluteFiles = ctx.targetFiles.map((f) => import_path.default.resolve(ctx.repositoryRoot, f));
|
|
@@ -2089,10 +2056,10 @@ var adapter = {
|
|
|
2089
2056
|
message: `flawfinder exited with code ${exitCode}${stderr ? `: ${stderr.trim()}` : ""}`,
|
|
2090
2057
|
level: "error"
|
|
2091
2058
|
});
|
|
2092
|
-
return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
2059
|
+
return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
2093
2060
|
}
|
|
2094
2061
|
if (!stdout.trim()) {
|
|
2095
|
-
return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
2062
|
+
return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
2096
2063
|
}
|
|
2097
2064
|
let sarif;
|
|
2098
2065
|
try {
|
|
@@ -2105,7 +2072,7 @@ var adapter = {
|
|
|
2105
2072
|
message: `Failed to parse flawfinder SARIF output: ${err instanceof Error ? err.message : String(err)}`,
|
|
2106
2073
|
level: "error"
|
|
2107
2074
|
});
|
|
2108
|
-
return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
2075
|
+
return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
|
|
2109
2076
|
}
|
|
2110
2077
|
const run = sarif.runs?.[0];
|
|
2111
2078
|
const results = run?.results ?? [];
|
|
@@ -2131,7 +2098,7 @@ var adapter = {
|
|
|
2131
2098
|
resultsByFile.set(absoluteFilePath, list);
|
|
2132
2099
|
}
|
|
2133
2100
|
for (const [absoluteFilePath, fileResults] of resultsByFile) {
|
|
2134
|
-
const lines = await readFileLines(absoluteFilePath);
|
|
2101
|
+
const lines = await (0, import_tooling.readFileLines)(absoluteFilePath);
|
|
2135
2102
|
const relPath = import_path.default.relative(ctx.repositoryRoot, absoluteFilePath);
|
|
2136
2103
|
for (const { result: result2, functionName, line, column } of fileResults) {
|
|
2137
2104
|
const patternId = (0, import_tooling.buildPatternId)(TOOL_ID, functionName);
|
|
@@ -2146,7 +2113,7 @@ var adapter = {
|
|
|
2146
2113
|
line,
|
|
2147
2114
|
column,
|
|
2148
2115
|
message: result2.message.text,
|
|
2149
|
-
lineContent: getLineContent(lines, line),
|
|
2116
|
+
lineContent: (0, import_tooling.getLineContent)(lines, line),
|
|
2150
2117
|
category: meta.category,
|
|
2151
2118
|
severity: meta.severity
|
|
2152
2119
|
});
|
|
@@ -2170,7 +2137,14 @@ var adapter = {
|
|
|
2170
2137
|
level: "error"
|
|
2171
2138
|
});
|
|
2172
2139
|
}
|
|
2173
|
-
const result =
|
|
2140
|
+
const result = (0, import_tooling.buildResult)(
|
|
2141
|
+
TOOL_ID,
|
|
2142
|
+
startedAt,
|
|
2143
|
+
/* @__PURE__ */ new Date(),
|
|
2144
|
+
issues,
|
|
2145
|
+
errors,
|
|
2146
|
+
ctx.targetFiles.length
|
|
2147
|
+
);
|
|
2174
2148
|
ctx.logger.info("Analysis complete", {
|
|
2175
2149
|
toolId: TOOL_ID,
|
|
2176
2150
|
issueCount: result.summary.issueCount,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AdapterDescriptor } from '@codacy/tooling';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Lightweight adapter descriptor for lazy loading.
|
|
5
|
+
*
|
|
6
|
+
* This module contains only plain-data metadata fields and has zero heavy
|
|
7
|
+
* imports (no patterns.json, no runtime utilities). The CLI imports this
|
|
8
|
+
* at startup for adapter registration without loading the full adapter module.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
declare const descriptor: AdapterDescriptor;
|
|
12
|
+
|
|
13
|
+
export { descriptor };
|
package/dist/metadata.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/metadata.ts
|
|
21
|
+
var metadata_exports = {};
|
|
22
|
+
__export(metadata_exports, {
|
|
23
|
+
descriptor: () => descriptor
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(metadata_exports);
|
|
26
|
+
var descriptor = {
|
|
27
|
+
id: "flawfinder",
|
|
28
|
+
displayName: "Flawfinder",
|
|
29
|
+
preferredVersion: "2.0.19",
|
|
30
|
+
languages: ["C", "CPP"],
|
|
31
|
+
filePatterns: ["**/*.c", "**/*.h", "**/*.cpp", "**/*.cc", "**/*.cxx", "**/*.hpp"],
|
|
32
|
+
supportedOS: ["linux", "darwin"],
|
|
33
|
+
supportedArch: ["x64", "arm64"],
|
|
34
|
+
supportedRunners: ["local", "container"]
|
|
35
|
+
};
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
descriptor
|
|
39
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codacy/tools-flawfinder-2",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Flawfinder adapter — CLI-mode C/C++ security analyzer",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@codacy/tooling": "0.
|
|
11
|
+
"@codacy/tooling": "0.5.0"
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": "Codacy <support@codacy.com> (https://www.codacy.com)",
|
|
@@ -21,8 +21,18 @@
|
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=20.0.0"
|
|
23
23
|
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./metadata": {
|
|
30
|
+
"types": "./dist/metadata.d.ts",
|
|
31
|
+
"default": "./dist/metadata.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
24
34
|
"scripts": {
|
|
25
|
-
"build": "tsup src/index.ts --format cjs --dts --clean",
|
|
35
|
+
"build": "tsup src/index.ts src/metadata.ts --format cjs --dts --clean",
|
|
26
36
|
"test": "vitest run",
|
|
27
37
|
"lint": "eslint src/",
|
|
28
38
|
"clean": "rm -rf dist",
|