@patrickdk77/office-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.
- package/dist/formulas.d.ts +4 -4
- package/dist/formulas.js +4 -4
- package/dist/odf.js +1 -1
- package/dist/ooxml.js +1 -1
- package/dist/xls.js +1 -1
- package/package.json +1 -1
package/dist/formulas.d.ts
CHANGED
|
@@ -9,17 +9,17 @@ export declare class Quotes {
|
|
|
9
9
|
outside(c: string): boolean;
|
|
10
10
|
}
|
|
11
11
|
/** What a function a formula calls does outside the file, or undefined when it does nothing there. */
|
|
12
|
-
export declare function riskyFunction(name: string): '
|
|
12
|
+
export declare function riskyFunction(name: string): 'load' | 'run' | undefined;
|
|
13
13
|
/** The functions, outside quotes, that a formula's text calls and that reach outside the file, as its text arrives. */
|
|
14
14
|
export declare class FunctionCalls {
|
|
15
15
|
private readonly quotes;
|
|
16
16
|
private word;
|
|
17
17
|
private spaced;
|
|
18
|
-
readonly found: Map<string, "
|
|
18
|
+
readonly found: Map<string, "load" | "run">;
|
|
19
19
|
write(t: string): void;
|
|
20
20
|
}
|
|
21
21
|
/** The functions a formula's whole text calls that reach outside the file. */
|
|
22
|
-
export declare function formulaCalls(formula: string): Map<string, '
|
|
22
|
+
export declare function formulaCalls(formula: string): Map<string, 'load' | 'run'>;
|
|
23
23
|
/** A name a BIFF formula token refers to: a defined name by index, or an external name through an XTI. */
|
|
24
24
|
export type BiffNameRef = {
|
|
25
25
|
kind: 'name';
|
|
@@ -34,7 +34,7 @@ export type BiffNameRef = {
|
|
|
34
34
|
* add-in and newer ones by the name the formula names them with, such as `_xlfn.WEBSERVICE`. The walk stops at a
|
|
35
35
|
* token it does not know the size of.
|
|
36
36
|
*/
|
|
37
|
-
export declare function biffCalls(rgce: Uint8Array, nameOf: (ref: BiffNameRef) => string | undefined): Map<string, '
|
|
37
|
+
export declare function biffCalls(rgce: Uint8Array, nameOf: (ref: BiffNameRef) => string | undefined): Map<string, 'load' | 'run'>;
|
|
38
38
|
/** Whether an OpenDocument formula calls the DDE function. */
|
|
39
39
|
export declare function callsDde(formula: string): boolean;
|
|
40
40
|
/** One word of a Word field code. A switch is an unquoted word that starts with a backslash. */
|
package/dist/formulas.js
CHANGED
|
@@ -35,18 +35,18 @@ class Quotes {
|
|
|
35
35
|
}
|
|
36
36
|
exports.Quotes = Quotes;
|
|
37
37
|
/**
|
|
38
|
-
* Functions that reach outside the file when a formula is calculated: WEBSERVICE and IMAGE
|
|
38
|
+
* Functions that reach outside the file when a formula is calculated: WEBSERVICE and IMAGE load a URL, RTD starts a
|
|
39
39
|
* COM server, CALL and REGISTER call into a DLL, and EXEC runs a program. A prefix such as `_xlfn.` or
|
|
40
40
|
* `COM.MICROSOFT.` names the same function.
|
|
41
41
|
*/
|
|
42
|
-
const
|
|
42
|
+
const LOAD = ['WEBSERVICE', 'IMAGE'];
|
|
43
43
|
const RUN = ['RTD', 'CALL', 'REGISTER', 'REGISTER.ID', 'EXEC'];
|
|
44
44
|
/** What a function a formula calls does outside the file, or undefined when it does nothing there. */
|
|
45
45
|
function riskyFunction(name) {
|
|
46
46
|
const n = name.toUpperCase();
|
|
47
47
|
const is = (f) => n === f || n.endsWith(`.${f}`);
|
|
48
|
-
if (
|
|
49
|
-
return '
|
|
48
|
+
if (LOAD.some(is))
|
|
49
|
+
return 'load';
|
|
50
50
|
if (RUN.some(is))
|
|
51
51
|
return 'run';
|
|
52
52
|
return undefined;
|
package/dist/odf.js
CHANGED
|
@@ -167,7 +167,7 @@ class EntryRules {
|
|
|
167
167
|
if ((0, formulas_1.callsDde)(a.value))
|
|
168
168
|
this.edit(this.report(types_1.OfficeCategory.Dde, types_1.OfficeDetail.Formula, { formula: (0, context_1.clip)(a.value) }), raw, strip);
|
|
169
169
|
for (const [fn, kind] of (0, formulas_1.formulaCalls)(a.value))
|
|
170
|
-
this.edit(this.report(kind === '
|
|
170
|
+
this.edit(this.report(kind === 'load' ? types_1.OfficeCategory.External : types_1.OfficeCategory.Macro, types_1.OfficeDetail.Formula, { function: (0, context_1.clip)(fn), formula: (0, context_1.clip)(a.value) }), raw, strip);
|
|
171
171
|
}
|
|
172
172
|
if (href === undefined || (0, links_1.isFragment)(href) || (el.ns === exports.NS.script && el.local === 'event-listener') || (el.ns === exports.NS.presentation && el.local === 'event-listener'))
|
|
173
173
|
return;
|
package/dist/ooxml.js
CHANGED
|
@@ -472,7 +472,7 @@ class PartRules {
|
|
|
472
472
|
this.remove(this.ctx.report(types_1.OfficeCategory.Dde, types_1.OfficeDetail.Formula, this.part, { formula: (0, context_1.clip)(shown.text), entity: (0, context_1.clip)(entity) }), this.formula);
|
|
473
473
|
if (!this.macroSheet)
|
|
474
474
|
for (const [fn, kind] of calls.found)
|
|
475
|
-
this.remove(this.ctx.report(kind === '
|
|
475
|
+
this.remove(this.ctx.report(kind === 'load' ? types_1.OfficeCategory.External : types_1.OfficeCategory.Macro, types_1.OfficeDetail.Formula, this.part, { function: (0, context_1.clip)(fn), formula: (0, context_1.clip)(shown.text) }), this.formula);
|
|
476
476
|
this.formula = undefined;
|
|
477
477
|
}
|
|
478
478
|
if (ns === VML_EXCEL_NS && el.local === 'FmlaMacro' && this.macroText) {
|
package/dist/xls.js
CHANGED
|
@@ -233,7 +233,7 @@ async function sheetRules(ctx, cfb, stream, s, decrypt, location, edits, control
|
|
|
233
233
|
continue;
|
|
234
234
|
const cce = b[at] | (b[at + 1] << 8);
|
|
235
235
|
for (const [fn, kind] of (0, formulas_1.biffCalls)(b.subarray(at + 2, at + 2 + cce), nameOf))
|
|
236
|
-
ctx.report(kind === '
|
|
236
|
+
ctx.report(kind === 'load' ? types_1.OfficeCategory.External : types_1.OfficeCategory.Macro, types_1.OfficeDetail.Formula, location, { sheet: (0, context_1.clip)(s.name), function: (0, context_1.clip)(fn) });
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patrickdk77/office-defuse",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Inspect Office and OpenDocument files for VBA and Excel 4.0 macros, LibreOffice Basic and scripts, DDE, external templates and links, embedded OLE objects and ActiveX controls, and score the risk. Strict ZIP and XML readers, bounded memory, no runtime dependencies.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "patrickdk77",
|