@iobroker/repochecker 5.19.10 → 5.19.12

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/README.md CHANGED
@@ -25,6 +25,14 @@ Example:
25
25
  Placeholder for the next version (at the beginning of the line):
26
26
  ### **WORK IN PROGRESS**
27
27
  -->
28
+ ### 5.19.12 (2026-07-13)
29
+
30
+ - (Copilot) Redact sensitive Axios error fields so `OWN_GITHUB_TOKEN`/authorization values are never logged in clear text.
31
+
32
+ ### 5.19.11 (2026-07-13)
33
+
34
+ - (Copilot) Send `OWN_GITHUB_TOKEN` only for GitHub URLs to avoid forwarding it to jsDelivr.
35
+
28
36
  ### 5.19.10 (2026-07-13)
29
37
 
30
38
  - (mcm1957) Workflow runs older than 90 days now emit a single suggestion instead of one per job log (S3056)
package/index.js CHANGED
@@ -182,8 +182,9 @@ function check(request, ctx, callback) {
182
182
  );
183
183
  })
184
184
  .catch(err => {
185
- console.error(`GLOBAL ERROR: ${err.toString()}, ${JSON.stringify(err)}`);
186
- context.errors.push(`[E9999] GLOBAL ERROR: ${err.toString()}, ${JSON.stringify(err)}`);
185
+ const sanitizedErrorJson = common.stringifyError(err);
186
+ console.error(`GLOBAL ERROR: ${err.toString()}, ${sanitizedErrorJson}`);
187
+ context.errors.push(`[E9999] GLOBAL ERROR: ${err.toString()}, ${sanitizedErrorJson}`);
187
188
 
188
189
  return callback(
189
190
  null,
@@ -30,10 +30,6 @@ axios.defaults.headers.common = {
30
30
  Expires: '0',
31
31
  };
32
32
 
33
- if (process.env.OWN_GITHUB_TOKEN) {
34
- axios.defaults.headers.common['Authorization'] = `Bearer ${process.env.OWN_GITHUB_TOKEN}`;
35
- }
36
-
37
33
  const common = require('./common.js');
38
34
  const M8900__Dependabot = require('./M8900__Dependabot.js');
39
35
 
package/lib/common.js CHANGED
@@ -8,12 +8,29 @@ const fs = require('node:fs/promises');
8
8
  const compareVersions = require('compare-versions');
9
9
  const semver = require('semver');
10
10
  const semverValid = require('semver/functions/valid');
11
+ const githubToken = process.env.OWN_GITHUB_TOKEN;
12
+ const redactedValue = '***REDACTED***';
11
13
 
12
14
  let gDebug = false;
13
15
  let gInfo = true;
14
16
  let gSuccess = false;
15
17
  let gLocal = false;
16
18
  let gStrict = false;
19
+ const githubHostnames = new Set([
20
+ 'github.com',
21
+ 'api.github.com',
22
+ 'gist.github.com',
23
+ 'codeload.github.com',
24
+ 'raw.githubusercontent.com',
25
+ 'gist.githubusercontent.com',
26
+ 'objects.githubusercontent.com',
27
+ 'uploads.github.com',
28
+ 'avatars.githubusercontent.com',
29
+ 'camo.githubusercontent.com',
30
+ 'media.githubusercontent.com',
31
+ 'user-images.githubusercontent.com',
32
+ 'private-user-images.githubusercontent.com',
33
+ ]);
17
34
 
18
35
  // Cache for getFilesList and getFile functions
19
36
  const filesListCache = new Map();
@@ -27,11 +44,33 @@ axios.defaults.headers.common = {
27
44
  // Authorization: process.env.OWN_GITHUB_TOKEN ? `token ${process.env.OWN_GITHUB_TOKEN}` : 'none',
28
45
  };
29
46
 
30
- if (process.env.OWN_GITHUB_TOKEN) {
31
- info('using authorization defined by OWN_GITHUB_TOKEN');
32
- axios.defaults.headers.common['Authorization'] = `Bearer ${process.env.OWN_GITHUB_TOKEN}`;
47
+ if (githubToken) {
48
+ info('using authorization defined by OWN_GITHUB_TOKEN for github URLs');
49
+ const githubAuthorization = 'Bearer ' + githubToken;
50
+ axios.interceptors.request.use(request => {
51
+ let parsedUrl;
52
+ try {
53
+ if (request?.url) {
54
+ parsedUrl = new URL(request.url, request.baseURL || undefined);
55
+ }
56
+ } catch {
57
+ parsedUrl = undefined;
58
+ }
59
+ const hostname = parsedUrl?.hostname?.toLowerCase();
60
+ const isGitHubUrl = !!hostname && githubHostnames.has(hostname);
61
+ if (isGitHubUrl) {
62
+ request.headers = request.headers || {};
63
+ request.headers.Authorization = githubAuthorization;
64
+ }
65
+ return request;
66
+ }, error => Promise.reject(error));
33
67
  }
34
68
 
69
+ axios.interceptors.response.use(
70
+ response => response,
71
+ error => Promise.reject(redactAxiosError(error)),
72
+ );
73
+
35
74
  // function log(msg) {
36
75
  // console.log(`${msg}`);
37
76
  // }
@@ -52,6 +91,80 @@ function error(msg) {
52
91
  console.error(`${msg ? '[ERROR] ' : ''}${msg}`);
53
92
  }
54
93
 
94
+ function isSensitiveKey(key) {
95
+ if (typeof key !== 'string') {
96
+ return false;
97
+ }
98
+ const normalizedKey = key.toLowerCase();
99
+ return (
100
+ normalizedKey.includes('authorization') ||
101
+ normalizedKey.includes('token') ||
102
+ normalizedKey.includes('api-key') ||
103
+ normalizedKey.includes('apikey') ||
104
+ normalizedKey.includes('secret') ||
105
+ normalizedKey.includes('password') ||
106
+ normalizedKey.includes('cookie')
107
+ );
108
+ }
109
+
110
+ function redactString(value) {
111
+ let result = value;
112
+ if (githubToken && result.includes(githubToken)) {
113
+ result = result.replaceAll(githubToken, redactedValue);
114
+ }
115
+ return result;
116
+ }
117
+
118
+ function redactSensitiveData(value, seen = new WeakSet()) {
119
+ if (!value || typeof value !== 'object') {
120
+ return typeof value === 'string' ? redactString(value) : value;
121
+ }
122
+ if (seen.has(value)) {
123
+ return value;
124
+ }
125
+ seen.add(value);
126
+
127
+ for (const key of Object.keys(value)) {
128
+ const entry = value[key];
129
+ if (isSensitiveKey(key)) {
130
+ value[key] = redactedValue;
131
+ } else if (typeof entry === 'string') {
132
+ value[key] = redactString(entry);
133
+ } else if (entry && typeof entry === 'object') {
134
+ redactSensitiveData(entry, seen);
135
+ }
136
+ }
137
+ return value;
138
+ }
139
+
140
+ function redactAxiosError(error) {
141
+ if (!error || typeof error !== 'object') {
142
+ return error;
143
+ }
144
+
145
+ redactSensitiveData(error);
146
+ return error;
147
+ }
148
+
149
+ function stringifyError(error) {
150
+ const sanitizedError = redactAxiosError(error);
151
+ try {
152
+ return JSON.stringify(sanitizedError);
153
+ } catch (serializationError) {
154
+ return JSON.stringify({
155
+ message: sanitizedError?.message,
156
+ code: sanitizedError?.code,
157
+ status: sanitizedError?.status,
158
+ config: sanitizedError?.config,
159
+ response: sanitizedError?.response && {
160
+ status: sanitizedError.response.status,
161
+ statusText: sanitizedError.response.statusText,
162
+ },
163
+ stringifyError: redactString(serializationError?.message || `${serializationError}`),
164
+ });
165
+ }
166
+ }
167
+
55
168
  function isDebug() {
56
169
  return gDebug;
57
170
  }
@@ -310,6 +423,8 @@ exports.debug = debug;
310
423
  exports.info = info;
311
424
  exports.error = error;
312
425
  exports.warn = warn;
426
+ exports.redactAxiosError = redactAxiosError;
427
+ exports.stringifyError = stringifyError;
313
428
 
314
429
  exports.isDebug = isDebug;
315
430
  exports.isInfo = isInfo;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.19.10",
2
+ "version": "5.19.12",
3
3
  "name": "@iobroker/repochecker",
4
4
  "dependencies": {
5
5
  "ajv": "^8.20.0",