@patrickdk77/script-defuse 0.3.0 → 0.3.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 (2) hide show
  1. package/dist/analyze.js +5 -5
  2. package/package.json +1 -1
package/dist/analyze.js CHANGED
@@ -196,10 +196,10 @@ function analyzeScript(input) {
196
196
  declare(program, top);
197
197
  // 2. What each binding is given: initializers and assignments. An assignment to a name nothing declares makes a
198
198
  // global, unless it is a property of the document, which an AcroForm script's bare names reach.
199
- const global = (name) => (!xfa && api_1.DOC_ALL.has(name) ? undefined : top.declare(name));
199
+ const declareGlobal = (name) => (!xfa && api_1.DOC_ALL.has(name) ? undefined : top.declare(name));
200
200
  const assign = (target, expr, scope) => {
201
201
  for (const name of patternNames(target)) {
202
- const b = scope.lookup(name) ?? global(name);
202
+ const b = scope.lookup(name) ?? declareGlobal(name);
203
203
  if (!b)
204
204
  continue;
205
205
  if (expr && target.type === 'Identifier')
@@ -231,11 +231,11 @@ function analyzeScript(input) {
231
231
  assign(n.left, n.right, scope);
232
232
  else
233
233
  for (const name of patternNames(n.left))
234
- (scope.lookup(name) ?? global(name))?.kinds.add(n.operator === '+=' ? 'data' : 'number');
234
+ (scope.lookup(name) ?? declareGlobal(name))?.kinds.add(n.operator === '+=' ? 'data' : 'number');
235
235
  }
236
236
  else if ((n.type === 'ForInStatement' || n.type === 'ForOfStatement') && n.left.type !== 'VariableDeclaration' && n.left.type !== 'MemberExpression') {
237
237
  for (const name of patternNames(n.left))
238
- (scope.lookup(name) ?? global(name))?.kinds.add(n.type === 'ForInStatement' ? 'string' : 'unknown');
238
+ (scope.lookup(name) ?? declareGlobal(name))?.kinds.add(n.type === 'ForInStatement' ? 'string' : 'unknown');
239
239
  }
240
240
  else if ((n.type === 'ForInStatement' || n.type === 'ForOfStatement') && n.left.type === 'VariableDeclaration') {
241
241
  for (const d of n.left.declarations)
@@ -243,7 +243,7 @@ function analyzeScript(input) {
243
243
  (scope.lookup(name) ?? scope.declare(name)).kinds.add(n.type === 'ForInStatement' ? 'string' : 'unknown');
244
244
  }
245
245
  else if (n.type === 'UpdateExpression' && n.argument.type === 'Identifier')
246
- (scope.lookup(n.argument.name) ?? global(n.argument.name))?.kinds.add('number');
246
+ (scope.lookup(n.argument.name) ?? declareGlobal(n.argument.name))?.kinds.add('number');
247
247
  for (const c of children(n))
248
248
  collect(c, inner);
249
249
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patrickdk77/script-defuse",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Inspect document scripts: PDF form scripts in JavaScript and FormCalc, from AcroForm and XFA forms, and the VBA modules of Office documents. Keeps a form script only when every call and property it uses formats, checks or calculates form fields, and a macro only when it calls nothing that reaches outside its document. Reports external access, dynamic code and obfuscation. Includes a script plugin for pdf-defuse and office-defuse.",
5
5
  "license": "MIT",
6
6
  "author": "patrickdk77",