ticketlens 0.38.40 → 0.38.41
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/package.json
CHANGED
|
@@ -172,34 +172,49 @@ const UNDERSCORE_COMPOUND_RE = /^[A-Za-z]+(_[A-Za-z]+)+$/;
|
|
|
172
172
|
// delimiters within one candidate would need.
|
|
173
173
|
const SLASH_PATH_RE = /^[A-Za-z0-9]+(\/[A-Za-z0-9]+)+\/?$/;
|
|
174
174
|
|
|
175
|
+
// PHP static method/property/const access (Class_Name::method,
|
|
176
|
+
// Class_Name::CONST), optionally prefixed by a leading backslash (PHP's
|
|
177
|
+
// fully-qualified global-namespace form — stripEdgePunctuation does not
|
|
178
|
+
// strip a LEADING backslash, only the trailing/leading punctuation in
|
|
179
|
+
// EDGE_PUNCTUATION_RE's class). The class part reuses the same shape as
|
|
180
|
+
// UNDERSCORE_COMPOUND_RE but allows a bare (non-underscore) class name too
|
|
181
|
+
// — real code has both ("Zend_Http_Client::GET" and "Router::dispatch").
|
|
182
|
+
// Found live: backlog #17's ORIGINAL bug report repro included this exact
|
|
183
|
+
// class+member shape (`Advent_Http_ClientFactory::clientForJson`,
|
|
184
|
+
// `Zend_Http_Client::GET`), but the first fix only covered the bare class
|
|
185
|
+
// name in isolation — the embedded "::member" broke UNDERSCORE_COMPOUND_RE's
|
|
186
|
+
// match (colons aren't letters/underscores) and no other exemption applied.
|
|
187
|
+
const STATIC_REFERENCE_RE = /^\\?([A-Za-z]+(?:_[A-Za-z]+)*)::([A-Za-z_][A-Za-z0-9_]*)$/;
|
|
188
|
+
|
|
175
189
|
/**
|
|
176
190
|
* Downgrade-only, same never-exempt treatment as looksLikeCodeFilename and
|
|
177
191
|
* looksLikeCodeSyntax below: true for a candidate shaped like a multi-segment
|
|
178
|
-
* code identifier (underscore-delimited PHP/Zend-1-style class name)
|
|
179
|
-
* namespace/filesystem path (slash-delimited),
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
192
|
+
* code identifier (underscore-delimited PHP/Zend-1-style class name), a
|
|
193
|
+
* namespace/filesystem path (slash-delimited), or a PHP static method/const
|
|
194
|
+
* reference (Class_Name::member, see STATIC_REFERENCE_RE), each segment
|
|
195
|
+
* capped at MAX_COMPOUND_SEGMENT_LENGTH so a long random run can't pose as
|
|
196
|
+
* one "segment" — same cap isHyphenatedWordCompound already uses. Backlog
|
|
197
|
+
* #17: isLabelWord's ordinary-word branch only matches letters-only tokens
|
|
198
|
+
* with no separator at all, and neither existing downgrade path below
|
|
199
|
+
* requires a file extension or bracket/paren — so a standalone identifier,
|
|
200
|
+
* path, or static reference like the three shapes above had no exemption
|
|
201
|
+
* path whatsoever, unlike a hyphenated compound or a dotted filename.
|
|
187
202
|
*
|
|
188
|
-
* A disguised real secret matching
|
|
189
|
-
* warning, never a silent pass — see the security regression tests
|
|
190
|
-
* alongside this function's own tests for
|
|
203
|
+
* A disguised real secret matching any of the three shapes still surfaces
|
|
204
|
+
* as a warning, never a silent pass — see the security regression tests
|
|
205
|
+
* alongside this function's own tests for all three shapes.
|
|
191
206
|
*
|
|
192
207
|
* Known accepted gap (security review, backlog #17): unlike
|
|
193
208
|
* isHyphenatedWordCompound, this has no whole-token case-switch guard (see
|
|
194
209
|
* UNDERSCORE_COMPOUND_RE's own comment for why one can't be added without
|
|
195
210
|
* rejecting the real Zend_Http_Client-shaped identifiers this exists to
|
|
196
211
|
* recognize) — so a uniform-case (all-upper or all-lower) letters-only
|
|
197
|
-
* secret needs only ONE underscore or
|
|
198
|
-
* full reject to a warning, no camouflage (fake extension, case
|
|
199
|
-
* required. Still never a silent pass — always a warning — so
|
|
200
|
-
* same class of trade-off as CODE_SYNTAX_RE's even less-
|
|
201
|
-
* downgrade above (any bracket/paren, no shape requirement at
|
|
202
|
-
* new exposure.
|
|
212
|
+
* secret needs only ONE underscore, slash, or "::" inserted to downgrade
|
|
213
|
+
* from a full reject to a warning, no camouflage (fake extension, case
|
|
214
|
+
* pattern) required. Still never a silent pass — always a warning — so
|
|
215
|
+
* this is the same class of trade-off as CODE_SYNTAX_RE's even less-
|
|
216
|
+
* constrained downgrade above (any bracket/paren, no shape requirement at
|
|
217
|
+
* all), not a new exposure.
|
|
203
218
|
*/
|
|
204
219
|
function looksLikeCodeIdentifierOrPath(rawToken) {
|
|
205
220
|
const stripped = stripEdgePunctuation(rawToken);
|
|
@@ -209,6 +224,12 @@ function looksLikeCodeIdentifierOrPath(rawToken) {
|
|
|
209
224
|
if (SLASH_PATH_RE.test(stripped)) {
|
|
210
225
|
return stripped.split('/').filter(Boolean).every(segment => segment.length <= MAX_COMPOUND_SEGMENT_LENGTH);
|
|
211
226
|
}
|
|
227
|
+
const staticRefMatch = stripped.match(STATIC_REFERENCE_RE);
|
|
228
|
+
if (staticRefMatch) {
|
|
229
|
+
const classSegmentsWithinCap = staticRefMatch[1].split('_').every(segment => segment.length <= MAX_COMPOUND_SEGMENT_LENGTH);
|
|
230
|
+
const memberWithinCap = staticRefMatch[2].length <= MAX_COMPOUND_SEGMENT_LENGTH;
|
|
231
|
+
return classSegmentsWithinCap && memberWithinCap;
|
|
232
|
+
}
|
|
212
233
|
return false;
|
|
213
234
|
}
|
|
214
235
|
|