Skip to content

Commit 59c1a1f

Browse files
fix: codescanning alerts (#2044)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent f13e7e3 commit 59c1a1f

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

.github/workflows/PR-SAP.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ concurrency:
99
group: pr-sap-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1010
cancel-in-progress: true
1111

12+
permissions:
13+
contents: read
14+
1215
jobs:
1316
build-sap:
1417
runs-on: ubuntu-latest

.github/workflows/PR.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ concurrency:
88
group: pr-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
99
cancel-in-progress: true
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
1215
build:
1316
runs-on: ubuntu-latest

tools/cds-lint/components/PlaygroundBadge.vue

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,12 @@ export default [
3333
3434
const defaultPackageJson = JSON.parse(data['package.json']);
3535
36-
function mergeJSONs(target: any, add: any) {
37-
const isObject = (obj: unknown) => typeof obj === 'object';
38-
Object.entries(add).forEach(([key, addVal]) => {
39-
const targetVal = target[key];
40-
if (targetVal && isObject(targetVal) && isObject(addVal)) {
41-
if ((Array.isArray(targetVal) && Array.isArray(addVal))) {
42-
targetVal.push(...addVal);
43-
return;
44-
}
45-
mergeJSONs(targetVal, addVal);
46-
} else {
47-
target[key] = addVal;
48-
}
49-
});
50-
return target;
36+
const is_object = x => typeof x === 'object' && x !== null && !Array.isArray(x)
37+
function merge (o:any,...xs:any) {
38+
let v:any; for (let x of xs) for (let k in x)
39+
if (k === '__proto__' || k === 'constructor') continue //> avoid prototype pollution
40+
else o[k] = is_object(v=x[k]) ? merge(o[k]??={},v) : v
41+
return o
5142
}
5243
5344
function link(name: Props['name'] = "", kind: Props['kind'], rules?: Props['rules'], files?: Props['files'], packages?: Props['packages'] ): string {
@@ -66,7 +57,7 @@ function link(name: Props['name'] = "", kind: Props['kind'], rules?: Props['rule
6657
sources[configFileName] = defaultConfig;
6758
}
6859
if (packages) {
69-
json = mergeJSONs(defaultPackageJson, packages);
60+
json = merge(defaultPackageJson, packages);
7061
} else {
7162
json = defaultPackageJson;
7263
}

0 commit comments

Comments
 (0)