opensecurity 0.2.1 → 0.3.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/README.md +2 -1
- package/dist/adapters/semgrep.js +1 -1
- package/dist/core/config.js +72 -0
- package/dist/core/scan.js +1336 -0
- package/dist/engines/analysis/ast.js +20 -0
- package/dist/engines/analysis/graphs.js +300 -0
- package/dist/engines/analysis/infraPatterns.js +196 -0
- package/dist/engines/analysis/patterns.js +237 -0
- package/dist/engines/analysis/rules.js +48 -0
- package/dist/engines/analysis/taint.js +294 -0
- package/dist/engines/analysis/universalPatterns.js +56 -0
- package/dist/engines/deps/cve.js +102 -0
- package/dist/engines/deps/engine.js +27 -0
- package/dist/engines/deps/patch.js +11 -0
- package/dist/engines/deps/scanners.js +114 -0
- package/dist/engines/deps/scoring.js +46 -0
- package/dist/engines/deps/simulate.js +9 -0
- package/dist/engines/deps/types.js +1 -0
- package/dist/engines/native/languages.js +222 -0
- package/dist/engines/native/loader.js +61 -0
- package/dist/engines/native/rules.js +14 -0
- package/dist/engines/native/taint.js +312 -0
- package/dist/engines/rules/defaultRules.js +177 -0
- package/dist/engines/rules/loadRules.js +14 -0
- package/dist/io/fileWalker.js +27 -0
- package/dist/io/login.js +583 -0
- package/dist/io/oauthStore.js +48 -0
- package/dist/io/proxy.js +93 -0
- package/dist/io/telemetry.js +72 -0
- package/dist/ui/cli.js +410 -0
- package/dist/ui/pr-comment.js +118 -0
- package/dist/ui/progress.js +150 -0
- package/package.json +5 -5
- package/rules/taint/c.json +38 -2
- package/rules/taint/cpp.json +38 -2
- package/rules/taint/go.json +16 -0
- package/rules/taint/kotlin.json +15 -0
- package/rules/taint/rust.json +16 -0
- package/rules/taint/swift.json +15 -0
package/README.md
CHANGED
|
@@ -303,7 +303,8 @@ Global config: `~/.config/opensecurity/config.json`
|
|
|
303
303
|
|
|
304
304
|
## Rules
|
|
305
305
|
|
|
306
|
-
Default rules are in `src/rules/defaultRules.ts`.
|
|
306
|
+
Default rules are in `src/engines/rules/defaultRules.ts`.
|
|
307
|
+
Taint rule coverage by language: `docs/coverage-matrix.md`.
|
|
307
308
|
You can override with a JSON file (`--rules` or `rulesPath`).
|
|
308
309
|
|
|
309
310
|
Pattern-based detectors run alongside rules (hardcoded secrets, insecure crypto, unsafe deserialization).
|
package/dist/adapters/semgrep.js
CHANGED
|
@@ -52,7 +52,7 @@ export const semgrepAdapter = {
|
|
|
52
52
|
description: item.extra?.message ?? "Semgrep issue detected.",
|
|
53
53
|
file: normalizePath(item.path ?? "", cwd),
|
|
54
54
|
line: item.start?.line ? Number(item.start.line) : undefined,
|
|
55
|
-
column: item.start?.col ? Number(item.start.col) : undefined,
|
|
55
|
+
column: item.start?.col ? Number(item.start.col) + 1 : undefined,
|
|
56
56
|
category: "code"
|
|
57
57
|
}));
|
|
58
58
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
export const DEFAULT_INCLUDE = ["**/*"];
|
|
5
|
+
export const DEFAULT_EXCLUDE = [
|
|
6
|
+
"**/.git/**",
|
|
7
|
+
"**/node_modules/**",
|
|
8
|
+
"**/dist/**",
|
|
9
|
+
"**/build/**",
|
|
10
|
+
"**/coverage/**",
|
|
11
|
+
"**/.opensecurity.json",
|
|
12
|
+
"**/.opensecurity-cache.json",
|
|
13
|
+
"**/.opensecurity/ai-cache.json",
|
|
14
|
+
"**/.opensecurity/native-taint-cache.json"
|
|
15
|
+
];
|
|
16
|
+
const DEFAULT_GLOBALS = {
|
|
17
|
+
baseUrl: "https://api.openai.com/v1/responses",
|
|
18
|
+
model: "gpt-4o-mini",
|
|
19
|
+
apiType: "responses",
|
|
20
|
+
provider: "openai"
|
|
21
|
+
};
|
|
22
|
+
export function getConfigDir(env = process.env) {
|
|
23
|
+
const override = env.OPENSECURITY_CONFIG_HOME;
|
|
24
|
+
if (override && override.trim())
|
|
25
|
+
return override;
|
|
26
|
+
return path.join(os.homedir(), ".config", "opensecurity");
|
|
27
|
+
}
|
|
28
|
+
export function getGlobalConfigPath(env = process.env) {
|
|
29
|
+
return path.join(getConfigDir(env), "config.json");
|
|
30
|
+
}
|
|
31
|
+
export function getProjectConfigPath(cwd = process.cwd()) {
|
|
32
|
+
return path.join(cwd, ".opensecurity.json");
|
|
33
|
+
}
|
|
34
|
+
async function readJsonFile(filePath) {
|
|
35
|
+
try {
|
|
36
|
+
const raw = await fs.readFile(filePath, "utf8");
|
|
37
|
+
return JSON.parse(raw);
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
if (err?.code === "ENOENT")
|
|
41
|
+
return null;
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async function writeJsonFile(filePath, data) {
|
|
46
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
47
|
+
await fs.writeFile(filePath, JSON.stringify(data, null, 2), "utf8");
|
|
48
|
+
}
|
|
49
|
+
export async function loadGlobalConfig(env = process.env) {
|
|
50
|
+
const filePath = getGlobalConfigPath(env);
|
|
51
|
+
const existing = await readJsonFile(filePath);
|
|
52
|
+
return {
|
|
53
|
+
...DEFAULT_GLOBALS,
|
|
54
|
+
...(existing ?? {})
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export async function saveGlobalConfig(config, env = process.env) {
|
|
58
|
+
const current = await loadGlobalConfig(env);
|
|
59
|
+
const merged = { ...current, ...config };
|
|
60
|
+
await writeJsonFile(getGlobalConfigPath(env), merged);
|
|
61
|
+
}
|
|
62
|
+
export async function loadProjectConfig(cwd = process.cwd()) {
|
|
63
|
+
const filePath = getProjectConfigPath(cwd);
|
|
64
|
+
const existing = await readJsonFile(filePath);
|
|
65
|
+
return existing ?? {};
|
|
66
|
+
}
|
|
67
|
+
export function resolveProjectFilters(project) {
|
|
68
|
+
return {
|
|
69
|
+
include: project.include?.length ? project.include : [...DEFAULT_INCLUDE],
|
|
70
|
+
exclude: project.exclude?.length ? project.exclude : [...DEFAULT_EXCLUDE]
|
|
71
|
+
};
|
|
72
|
+
}
|