@appthreat/atom 2.4.0 → 2.4.1

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.
Files changed (25) hide show
  1. package/package.json +1 -1
  2. package/packages/atom-parsetools/astgen.js +67 -17
  3. package/plugins/bin/atom +1 -1
  4. package/plugins/bin/atom.bat +1 -1
  5. package/plugins/lib/io.appthreat.atom-2.4.1-classpath.jar +0 -0
  6. package/plugins/lib/{io.appthreat.atom-2.4.0.jar → io.appthreat.atom-2.4.1.jar} +0 -0
  7. package/plugins/lib/{io.appthreat.c2cpg_3-2.5.1.jar → io.appthreat.c2cpg_3-2.5.3.jar} +0 -0
  8. package/plugins/lib/{io.appthreat.cpg2-domain-classes_3-1.1.1.jar → io.appthreat.cpg2-domain-classes_3-2.0.0.jar} +0 -0
  9. package/plugins/lib/{io.appthreat.cpg2-protos_3-1.1.1.jar → io.appthreat.cpg2-protos_3-2.0.0.jar} +0 -0
  10. package/plugins/lib/{io.appthreat.cpg2_3-1.1.1.jar → io.appthreat.cpg2_3-2.0.0.jar} +0 -0
  11. package/plugins/lib/{io.appthreat.dataflowengineoss_3-2.5.1.jar → io.appthreat.dataflowengineoss_3-2.5.3.jar} +0 -0
  12. package/plugins/lib/{io.appthreat.javasrc2cpg_3-2.5.1.jar → io.appthreat.javasrc2cpg_3-2.5.3.jar} +0 -0
  13. package/plugins/lib/{io.appthreat.jimple2cpg_3-2.5.1.jar → io.appthreat.jimple2cpg_3-2.5.3.jar} +0 -0
  14. package/plugins/lib/{io.appthreat.jssrc2cpg_3-2.5.1.jar → io.appthreat.jssrc2cpg_3-2.5.3.jar} +0 -0
  15. package/plugins/lib/io.appthreat.odb2-core_3-2.0.0.jar +0 -0
  16. package/plugins/lib/{io.appthreat.odb2-formats_3-1.0.1.jar → io.appthreat.odb2-formats_3-2.0.0.jar} +0 -0
  17. package/plugins/lib/io.appthreat.odb2-traversal_3-2.0.0.jar +0 -0
  18. package/plugins/lib/{io.appthreat.php2atom_3-2.5.1.jar → io.appthreat.php2atom_3-2.5.3.jar} +0 -0
  19. package/plugins/lib/{io.appthreat.pysrc2cpg_3-2.5.1.jar → io.appthreat.pysrc2cpg_3-2.5.3.jar} +0 -0
  20. package/plugins/lib/{io.appthreat.ruby2atom_3-2.5.1.jar → io.appthreat.ruby2atom_3-2.5.3.jar} +0 -0
  21. package/plugins/lib/{io.appthreat.semanticcpg_3-2.5.1.jar → io.appthreat.semanticcpg_3-2.5.3.jar} +0 -0
  22. package/plugins/lib/{io.appthreat.x2cpg_3-2.5.1.jar → io.appthreat.x2cpg_3-2.5.3.jar} +0 -0
  23. package/plugins/lib/io.appthreat.atom-2.4.0-classpath.jar +0 -0
  24. package/plugins/lib/io.appthreat.odb2-core_3-1.0.1.jar +0 -0
  25. package/plugins/lib/io.appthreat.odb2-traversal_3-1.0.1.jar +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appthreat/atom",
3
- "version": "2.4.0",
3
+ "version": "2.4.1",
4
4
  "description": "Create atom (⚛) representation for your application, packages and libraries",
5
5
  "exports": "./index.js",
6
6
  "type": "module",
@@ -59,17 +59,53 @@ const babelSafeParserOptions = {
59
59
 
60
60
  /**
61
61
  * Return paths to all (j|tsx?) files.
62
+ * Optionally includes specific bundled files from node_modules if:
63
+ * 1. ASTGEN_INCLUDE_NODE_MODULES_BUNDLES is "true", OR
64
+ * 2. ASTGEN_IGNORE_DIRS is non-empty and doesn't include "node_modules"
62
65
  */
63
- const getAllSrcJSAndTSFiles = (src) =>
64
- Promise.all([
66
+ const getAllSrcJSAndTSFiles = (src) => {
67
+ const filePattern = "\\.(js|jsx|cjs|mjs|ts|tsx|vue|svelte|xsjs|xsjslib|ejs)$";
68
+ const bundledNodeModulesPattern =
69
+ "node_modules/.*\\.(bundle|dist|index|min|app)\\.(js|cjs|mjs)$";
70
+
71
+ // Step 1: Collect all JS/TS files EXCLUDING node_modules
72
+ const allFilesPromise = Promise.resolve(
65
73
  getAllFiles(
66
74
  src,
67
75
  undefined,
68
76
  undefined,
69
77
  undefined,
70
- new RegExp("\\.(js|jsx|cjs|mjs|ts|tsx|vue|svelte)$")
78
+ new RegExp(filePattern),
79
+ true // ignore node_modules
71
80
  )
72
- ]);
81
+ );
82
+
83
+ // Step 2: Check if we should include node_modules bundles
84
+ const shouldIncludeNodeModulesBundles =
85
+ process.env?.ASTGEN_INCLUDE_NODE_MODULES_BUNDLES === "true" ||
86
+ (process.env?.ASTGEN_IGNORE_DIRS &&
87
+ process.env.ASTGEN_IGNORE_DIRS.length > 0 &&
88
+ !process.env.ASTGEN_IGNORE_DIRS.toLowerCase().includes("node_modules"));
89
+
90
+ let bundledFilesPromise = Promise.resolve([]);
91
+ if (shouldIncludeNodeModulesBundles) {
92
+ bundledFilesPromise = Promise.resolve(
93
+ getAllFiles(
94
+ src,
95
+ undefined,
96
+ undefined,
97
+ undefined,
98
+ new RegExp(bundledNodeModulesPattern),
99
+ false // DO NOT ignore node_modules
100
+ )
101
+ );
102
+ }
103
+
104
+ // Step 3: Combine both lists
105
+ return Promise.all([allFilesPromise, bundledFilesPromise]).then(
106
+ ([allFiles, bundledFiles]) => [...allFiles, ...bundledFiles]
107
+ );
108
+ };
73
109
 
74
110
  /**
75
111
  * Convert a single JS/TS file to AST
@@ -242,30 +278,44 @@ const createJSAst = async (options) => {
242
278
  try {
243
279
  const promiseMap = await getAllSrcJSAndTSFiles(options.src);
244
280
  const srcFiles = promiseMap.flatMap((d) => d);
281
+ const CONCURRENCY_LIMIT = 10;
282
+ const chunks = [];
283
+ for (let i = 0; i < srcFiles.length; i += CONCURRENCY_LIMIT) {
284
+ chunks.push(srcFiles.slice(i, i + CONCURRENCY_LIMIT));
285
+ }
245
286
  let ts;
246
287
  if (options.tsTypes) {
247
- ts = createTsc(srcFiles);
288
+ const projectFiles = srcFiles.filter(
289
+ (file) => !file.includes("node_modules")
290
+ );
291
+ ts = createTsc(projectFiles);
248
292
  }
249
- for (const file of srcFiles) {
293
+ for (const chunk of chunks) {
294
+ await Promise.all(chunk.map((file) => processFile(file, options, ts)));
295
+ }
296
+ } catch (err) {
297
+ console.error(err);
298
+ }
299
+ };
300
+
301
+ const processFile = (file, options, ts) => {
302
+ try {
303
+ const ast = fileToJsAst(file);
304
+ writeAstFile(file, ast, options);
305
+ if (ts) {
250
306
  try {
251
- const ast = fileToJsAst(file);
252
- writeAstFile(file, ast, options);
253
- } catch (err) {
254
- console.error(file, err.message);
255
- }
256
- if (ts) {
257
- try {
258
- const tsAst = ts.program.getSourceFile(file);
307
+ const tsAst = ts.program.getSourceFile(file);
308
+ if (tsAst) {
259
309
  tsc.forEachChild(tsAst, ts.addType);
260
310
  writeTypesFile(file, ts.seenTypes, options);
261
311
  ts.seenTypes.clear();
262
- } catch (err) {
263
- console.warn("Retrieving types", file, ":", err.message);
264
312
  }
313
+ } catch (err) {
314
+ console.warn("Retrieving types", file, ":", err.message);
265
315
  }
266
316
  }
267
317
  } catch (err) {
268
- console.error(err);
318
+ console.error(file, err.message);
269
319
  }
270
320
  };
271
321
 
package/plugins/bin/atom CHANGED
@@ -360,7 +360,7 @@ declare -r lib_dir="$(realpath "${app_home}/../lib")"
360
360
  declare -a app_mainclass=('io.appthreat.atom.Atom')
361
361
 
362
362
  declare -r script_conf_file="${app_home}/../conf/application.ini"
363
- declare -r app_classpath="$lib_dir/io.appthreat.atom-2.4.0-classpath.jar"
363
+ declare -r app_classpath="$lib_dir/io.appthreat.atom-2.4.1-classpath.jar"
364
364
 
365
365
  # java_cmd is overrode in process_args when -java-home is used
366
366
  declare java_cmd=$(get_java_cmd)
@@ -40,7 +40,7 @@ rem "-J" is stripped, "-D" is left as is, and everything is appended to JAVA_OPT
40
40
  set _JAVA_PARAMS=
41
41
  set _APP_ARGS=
42
42
 
43
- set "APP_CLASSPATH=%APP_LIB_DIR%\io.appthreat.atom-2.4.0-classpath.jar"
43
+ set "APP_CLASSPATH=%APP_LIB_DIR%\io.appthreat.atom-2.4.1-classpath.jar"
44
44
  set "APP_MAIN_CLASS=io.appthreat.atom.Atom"
45
45
  set "SCRIPT_CONF_FILE=%APP_HOME%\conf\application.ini"
46
46
 
index 7a06df4..9381a08 100644
Binary file
index f022ed0..857925d 100644
Binary file
index 7872971..1d95b64 100644
Binary file
index 1932476..8cec9a5 100644
Binary file