Skip to content

Commit 8c2ff5a

Browse files
committed
refactor: handle unknown permissions safely
Add fallback handling for unknown permissions, effectively handle empty permission sets, and refine label notes and categories.
1 parent af9ddb4 commit 8c2ff5a

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

backend/src/routes/label.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ router.get("/app/:slug/label", async (_req, res) => {
1111
([name, access]) => ({ name, access })
1212
);
1313

14+
if (perms.length === 0) {
15+
return res.json(buildLabel([]));
16+
}
17+
1418
res.json(buildLabel(perms));
1519
} catch (err) {
1620
console.error(err.response?.data || err.message);

backend/src/services/privacyLabel.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ function buildLabel(perms) {
66

77
perms.forEach(({ name }) => {
88
const perm = permissions[name];
9-
if (!perm) return;
9+
if (!perm) {
10+
used.add("unknown");
11+
return;
12+
}
1013

1114
const key = perm.category;
1215
used.add(key);
@@ -26,8 +29,8 @@ function buildLabel(perms) {
2629
overall_sensitivity: sensitivity,
2730
permissions: perms,
2831
notes: [
29-
"Based on publicly available GitHub App permission metadata.",
30-
"Does not inspect runtime behavior or private repositories.",
32+
"Derived from declared GitHub App permissions.",
33+
"Based on public metadata only; no runtime inspection.",
3134
],
3235
};
3336
}

shared/categories.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,10 @@
2828
"label": "Organization-level access",
2929
"sensitivity": "high",
3030
"description": "Permissions that apply across an organization rather than individual repositories."
31+
},
32+
"unknown": {
33+
"label": "Unknown data access",
34+
"sensitivity": "moderate",
35+
"description": "Permissions not yet classified by PermLens."
3136
}
3237
}

0 commit comments

Comments
 (0)