Skip to content

Commit 01d75be

Browse files
authored
Fix TypeErrors in list_apps and list_entitlements (#26)
* Fix dir creation bug * Fix TypeError in list_apps and list_entitlements
1 parent 97367d9 commit 01d75be

3 files changed

Lines changed: 10 additions & 11 deletions

File tree

Payload_Type/apfell/apfell/agent_code/list_apps.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ exports.list_apps = function(task, command, params){
77
let info = {};
88
info['frontMost'] = procs[i].active;
99
info['hidden'] = procs[i].hidden;
10-
info['bundle'] = procs[i].bundleIdentifier.js;
11-
info['bundleURL'] = procs[i].bundleURL.path.js;
12-
info['bin_path'] = procs[i].executableURL.path.js;
10+
info['bundle'] = procs[i].bundleIdentifier ? procs[i].bundleIdentifier.js : "";
11+
info['bundleURL'] = (procs[i].bundleURL && procs[i].bundleURL.path) ? procs[i].bundleURL.path.js : "";
12+
info['bin_path'] = (procs[i].executableURL && procs[i].executableURL.path) ? procs[i].executableURL.path.js : "";
1313
info['process_id'] = procs[i].processIdentifier;
1414
info['name'] = procs[i].localizedName.js;
1515
if(procs[i].executableArchitecture === "16777223"){

Payload_Type/apfell/apfell/agent_code/list_entitlements.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ exports.list_entitlements = function(task, command, params){
2828
ent = {};
2929
}
3030
entitlements["pid"] = procs[i].processIdentifier;
31-
entitlements['bundle'] = procs[i].bundleIdentifier.js;
32-
entitlements['bundleURL'] = procs[i].bundleURL.path.js;
33-
entitlements['bin_path'] = procs[i].executableURL.path.js;
34-
entitlements['name'] = procs[i].localizedName.js;
31+
entitlements['bundle'] = procs[i].bundleIdentifier ? procs[i].bundleIdentifier.js : "";
32+
entitlements['bundleURL'] = (procs[i].bundleURL && procs[i].bundleURL.path) ? procs[i].bundleURL.path.js : "";
33+
entitlements['bin_path'] = (procs[i].executableURL && procs[i].executableURL.path) ? procs[i].executableURL.path.js : "";
34+
entitlements['name'] = procs[i].localizedName ? procs[i].localizedName.js : "";
3535
entitlements["entitlements"] = ent;
3636
output.push(entitlements);
3737
}

documentation-payload/apfell/commands/list_apps.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ for(let i = 0; i < procs.length; i++){
3131
let info = {};
3232
info['frontMost'] = procs[i].active;
3333
info['hidden'] = procs[i].hidden;
34-
info['bundle'] = procs[i].bundleIdentifier.js;
35-
info['bundleURL'] = procs[i].bundleURL.path.js;
36-
info['bin_path'] = procs[i].executableURL.path.js;
34+
info['bundle'] = procs[i].bundleIdentifier ? procs[i].bundleIdentifier.js : "";
35+
info['bundleURL'] = (procs[i].bundleURL && procs[i].bundleURL.path) ? procs[i].bundleURL.path.js : "";
36+
info['bin_path'] = (procs[i].executableURL && procs[i].executableURL.path) ? procs[i].executableURL.path.js : "";
3737
info['process_id'] = procs[i].processIdentifier;
3838
info['name'] = procs[i].localizedName.js;
3939
if(procs[i].executableArchitecture === "16777223"){
@@ -57,4 +57,3 @@ This output is turned into a sortable table via a browserscript that by default
5757
- Terminal
5858
- 1Password
5959
- Slack
60-

0 commit comments

Comments
 (0)