pumuki 6.3.207 → 6.3.208
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/core/facts/detectors/text/ios.test.ts +51 -0
- package/core/facts/detectors/text/ios.ts +69 -0
- package/core/facts/extractHeuristicFacts.ts +1 -0
- package/core/rules/presets/heuristics/ios.ts +19 -0
- package/integrations/config/skillsDetectorRegistry.ts +5 -2
- package/integrations/config/skillsMarkdownRules.ts +6 -3
- package/package.json +1 -1
- package/skills.lock.json +14 -26
|
@@ -55,6 +55,7 @@ import {
|
|
|
55
55
|
hasSwiftJSONSerializationUsage,
|
|
56
56
|
hasSwiftStringFormatUsage,
|
|
57
57
|
hasSwiftStrongDelegateReferenceUsage,
|
|
58
|
+
hasSwiftStrongSelfEscapingClosureUsage,
|
|
58
59
|
hasSwiftTabItemUsage,
|
|
59
60
|
hasSwiftTaskDetachedUsage,
|
|
60
61
|
hasSwiftWaitForExpectationsUsage,
|
|
@@ -209,6 +210,56 @@ final class CheckoutCoordinator {
|
|
|
209
210
|
assert.equal(hasSwiftStrongDelegateReferenceUsage(source), false);
|
|
210
211
|
});
|
|
211
212
|
|
|
213
|
+
test('hasSwiftStrongSelfEscapingClosureUsage detecta self fuerte en closures escapables iOS', () => {
|
|
214
|
+
const source = `
|
|
215
|
+
final class CartViewModel {
|
|
216
|
+
private var cancellables = Set<AnyCancellable>()
|
|
217
|
+
|
|
218
|
+
func bind() {
|
|
219
|
+
Task {
|
|
220
|
+
await self.reload()
|
|
221
|
+
}
|
|
222
|
+
DispatchQueue.main.async {
|
|
223
|
+
self.render()
|
|
224
|
+
}
|
|
225
|
+
Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { timer in
|
|
226
|
+
self.tick(timer)
|
|
227
|
+
}
|
|
228
|
+
NotificationCenter.default.addObserver(forName: .cartChanged, object: nil, queue: .main) { notification in
|
|
229
|
+
self.handle(notification)
|
|
230
|
+
}
|
|
231
|
+
publisher.sink { value in
|
|
232
|
+
self.consume(value)
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
`;
|
|
237
|
+
|
|
238
|
+
assert.equal(hasSwiftStrongSelfEscapingClosureUsage(source), true);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
test('hasSwiftStrongSelfEscapingClosureUsage preserva capture lists weak/unowned e ignora comentarios y strings', () => {
|
|
242
|
+
const source = `
|
|
243
|
+
final class CartViewModel {
|
|
244
|
+
func bind() {
|
|
245
|
+
Task { [weak self] in
|
|
246
|
+
await self?.reload()
|
|
247
|
+
}
|
|
248
|
+
DispatchQueue.main.async { [unowned self] in
|
|
249
|
+
render()
|
|
250
|
+
}
|
|
251
|
+
publisher.sink(receiveValue: { [weak self] value in
|
|
252
|
+
self?.consume(value)
|
|
253
|
+
})
|
|
254
|
+
let text = "Task { self.reload() }"
|
|
255
|
+
// Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { _ in self.tick() }
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
`;
|
|
259
|
+
|
|
260
|
+
assert.equal(hasSwiftStrongSelfEscapingClosureUsage(source), false);
|
|
261
|
+
});
|
|
262
|
+
|
|
212
263
|
test('detectores de logging iOS detectan logs ad-hoc y PII en produccion', () => {
|
|
213
264
|
const adHoc = `
|
|
214
265
|
print(user.id)
|
|
@@ -450,6 +450,75 @@ export const hasSwiftStrongDelegateReferenceUsage = (source: string): boolean =>
|
|
|
450
450
|
});
|
|
451
451
|
};
|
|
452
452
|
|
|
453
|
+
const swiftStrongSelfEscapingClosurePatterns = [
|
|
454
|
+
/\bTask\s*(?:\([^)]*\))?\s*\{/g,
|
|
455
|
+
/\bDispatchQueue\s*\.\s*[A-Za-z0-9_.]+\s*\.\s*async(?:After)?\s*(?:\([^)]*\))?\s*\{/g,
|
|
456
|
+
/\bTimer\s*\.\s*scheduledTimer\s*\([\s\S]{0,320}?\)\s*\{/g,
|
|
457
|
+
/\bNotificationCenter\s*\.\s*default\s*\.\s*addObserver\s*\([\s\S]{0,420}?\busing\s*:\s*\{/g,
|
|
458
|
+
/\.\s*sink\s*\([\s\S]{0,420}?\b(?:receiveValue|receiveCompletion)\s*:\s*\{/g,
|
|
459
|
+
/\.\s*sink\s*\{/g,
|
|
460
|
+
/\.\s*handleEvents\s*\([\s\S]{0,420}?\b(?:receiveOutput|receiveCompletion|receiveCancel)\s*:\s*\{/g,
|
|
461
|
+
];
|
|
462
|
+
|
|
463
|
+
const findMatchingSwiftBraceIndex = (source: string, openingBraceIndex: number): number => {
|
|
464
|
+
let depth = 0;
|
|
465
|
+
for (let index = openingBraceIndex; index < source.length; index += 1) {
|
|
466
|
+
const char = source[index];
|
|
467
|
+
if (char === '{') {
|
|
468
|
+
depth += 1;
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
if (char !== '}') {
|
|
472
|
+
continue;
|
|
473
|
+
}
|
|
474
|
+
depth -= 1;
|
|
475
|
+
if (depth === 0) {
|
|
476
|
+
return index;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return -1;
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
const hasWeakOrUnownedSelfCaptureList = (closureBody: string): boolean => {
|
|
483
|
+
const trimmedStart = closureBody.trimStart();
|
|
484
|
+
if (!trimmedStart.startsWith('[')) {
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
const captureListEndIndex = trimmedStart.indexOf(']');
|
|
488
|
+
if (captureListEndIndex < 0) {
|
|
489
|
+
return false;
|
|
490
|
+
}
|
|
491
|
+
const captureList = trimmedStart.slice(1, captureListEndIndex);
|
|
492
|
+
return /\b(?:weak|unowned)\s+self\b/.test(captureList);
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
export const hasSwiftStrongSelfEscapingClosureUsage = (source: string): boolean => {
|
|
496
|
+
const sanitized = sanitizeSwiftSourceForMultilineRegex(source);
|
|
497
|
+
for (const pattern of swiftStrongSelfEscapingClosurePatterns) {
|
|
498
|
+
pattern.lastIndex = 0;
|
|
499
|
+
for (const match of sanitized.matchAll(pattern)) {
|
|
500
|
+
const matchedSource = match[0] ?? '';
|
|
501
|
+
const openingBraceOffset = matchedSource.lastIndexOf('{');
|
|
502
|
+
if (openingBraceOffset < 0 || match.index === undefined) {
|
|
503
|
+
continue;
|
|
504
|
+
}
|
|
505
|
+
const openingBraceIndex = match.index + openingBraceOffset;
|
|
506
|
+
const closingBraceIndex = findMatchingSwiftBraceIndex(sanitized, openingBraceIndex);
|
|
507
|
+
if (closingBraceIndex < 0) {
|
|
508
|
+
continue;
|
|
509
|
+
}
|
|
510
|
+
const closureBody = sanitized.slice(openingBraceIndex + 1, closingBraceIndex);
|
|
511
|
+
if (hasWeakOrUnownedSelfCaptureList(closureBody)) {
|
|
512
|
+
continue;
|
|
513
|
+
}
|
|
514
|
+
if (/\bself\s*\./.test(closureBody)) {
|
|
515
|
+
return true;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return false;
|
|
520
|
+
};
|
|
521
|
+
|
|
453
522
|
export const hasSwiftAdHocLoggingUsage = (source: string): boolean => {
|
|
454
523
|
return collectSwiftRegexLines(
|
|
455
524
|
source,
|
|
@@ -647,6 +647,7 @@ const textDetectorRegistry: ReadonlyArray<TextDetectorRegistryEntry> = [
|
|
|
647
647
|
{ platform: 'ios', pathCheck: isIOSSwiftPath, excludePaths: [isSwiftTestPath], detect: TextIOS.hasSwiftOperationQueueUsage, ruleId: 'heuristics.ios.operation-queue.ast', code: 'HEURISTICS_IOS_OPERATION_QUEUE_AST', message: 'AST heuristic detected OperationQueue usage.' },
|
|
648
648
|
{ platform: 'ios', pathCheck: isIOSSwiftPath, excludePaths: [isSwiftTestPath], detect: TextIOS.hasSwiftTaskDetachedUsage, ruleId: 'heuristics.ios.task-detached.ast', code: 'HEURISTICS_IOS_TASK_DETACHED_AST', message: 'AST heuristic detected Task.detached usage.' },
|
|
649
649
|
{ platform: 'ios', pathCheck: isIOSSwiftPath, excludePaths: [isSwiftTestPath], detect: TextIOS.hasSwiftStrongDelegateReferenceUsage, ruleId: 'heuristics.ios.memory.strong-delegate.ast', code: 'HEURISTICS_IOS_MEMORY_STRONG_DELEGATE_AST', message: 'AST heuristic detected a strong delegate/dataSource reference; weak delegates remain the preferred baseline to avoid retain cycles.' },
|
|
650
|
+
{ platform: 'ios', pathCheck: isIOSSwiftPath, excludePaths: [isSwiftTestPath], detect: TextIOS.hasSwiftStrongSelfEscapingClosureUsage, ruleId: 'heuristics.ios.memory.strong-self-escaping-closure.ast', code: 'HEURISTICS_IOS_MEMORY_STRONG_SELF_ESCAPING_CLOSURE_AST', message: 'AST heuristic detected strong self capture in an escaping iOS closure; weak or unowned captures remain the preferred baseline when ownership is not explicit.' },
|
|
650
651
|
{ platform: 'ios', pathCheck: isIOSSwiftPath, excludePaths: [isSwiftTestPath], detect: TextIOS.hasSwiftAdHocLoggingUsage, ruleId: 'heuristics.ios.logging.adhoc-print.ast', code: 'HEURISTICS_IOS_LOGGING_ADHOC_PRINT_AST', message: 'AST heuristic detected print/debugPrint/dump/NSLog/os_log usage in iOS production code.' },
|
|
651
652
|
{ platform: 'ios', pathCheck: isIOSSwiftPath, excludePaths: [isSwiftTestPath], detect: TextIOS.hasSwiftSensitiveLoggingUsage, ruleId: 'heuristics.ios.logging.sensitive-data.ast', code: 'HEURISTICS_IOS_LOGGING_SENSITIVE_DATA_AST', message: 'AST heuristic detected sensitive data in an iOS logging call.' },
|
|
652
653
|
{ platform: 'ios', pathCheck: isIOSSwiftPath, excludePaths: [isSwiftTestPath], detect: TextIOS.hasSwiftAlamofireUsage, ruleId: 'heuristics.ios.networking.alamofire.ast', code: 'HEURISTICS_IOS_NETWORKING_ALAMOFIRE_AST', message: 'AST heuristic detected Alamofire usage in iOS production code; URLSession remains the preferred baseline for new code.' },
|
|
@@ -200,6 +200,25 @@ export const iosRules: RuleSet = [
|
|
|
200
200
|
code: 'HEURISTICS_IOS_MEMORY_STRONG_DELEGATE_AST',
|
|
201
201
|
},
|
|
202
202
|
},
|
|
203
|
+
{
|
|
204
|
+
id: 'heuristics.ios.memory.strong-self-escaping-closure.ast',
|
|
205
|
+
description: 'Detects strong self captures in escaping iOS closures.',
|
|
206
|
+
severity: 'WARN',
|
|
207
|
+
platform: 'ios',
|
|
208
|
+
locked: true,
|
|
209
|
+
when: {
|
|
210
|
+
kind: 'Heuristic',
|
|
211
|
+
where: {
|
|
212
|
+
ruleId: 'heuristics.ios.memory.strong-self-escaping-closure.ast',
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
then: {
|
|
216
|
+
kind: 'Finding',
|
|
217
|
+
message:
|
|
218
|
+
'AST heuristic detected strong self capture in an escaping iOS closure; weak or unowned captures remain the preferred baseline when ownership is not explicit.',
|
|
219
|
+
code: 'HEURISTICS_IOS_MEMORY_STRONG_SELF_ESCAPING_CLOSURE_AST',
|
|
220
|
+
},
|
|
221
|
+
},
|
|
203
222
|
{
|
|
204
223
|
id: 'heuristics.ios.logging.adhoc-print.ast',
|
|
205
224
|
description: 'Detects print/debugPrint/dump/NSLog/os_log usage in iOS production code.',
|
|
@@ -52,8 +52,11 @@ const registryByRuleId: Record<string, SkillsDetectorBinding> = {
|
|
|
52
52
|
['heuristics.ios.memory.strong-delegate.ast']
|
|
53
53
|
),
|
|
54
54
|
'skills.ios.guideline.ios.evitar-retain-cycles-especialmente-en-closures-delegates': heuristicDetector(
|
|
55
|
-
'ios.memory.
|
|
56
|
-
[
|
|
55
|
+
'ios.memory.retain-cycles',
|
|
56
|
+
[
|
|
57
|
+
'heuristics.ios.memory.strong-delegate.ast',
|
|
58
|
+
'heuristics.ios.memory.strong-self-escaping-closure.ast',
|
|
59
|
+
]
|
|
57
60
|
),
|
|
58
61
|
'skills.ios.guideline.ios.prohibido-print-y-logs-ad-hoc': heuristicDetector(
|
|
59
62
|
'ios.logging.adhoc-print',
|
|
@@ -423,14 +423,17 @@ const normalizeKnownRuleTarget = (
|
|
|
423
423
|
) {
|
|
424
424
|
return 'skills.ios.guideline.ios.accessibility-labels-accessibilitylabel';
|
|
425
425
|
}
|
|
426
|
+
if (includes('weak delegates') || includes('delegation pattern')) {
|
|
427
|
+
return 'skills.ios.guideline.ios.delegation-pattern-weak-delegates-para-evitar-retain-cycles';
|
|
428
|
+
}
|
|
426
429
|
if (
|
|
427
|
-
includes('weak delegates') ||
|
|
428
|
-
includes('delegation pattern') ||
|
|
429
430
|
includes('closures delegates') ||
|
|
431
|
+
includes('weak self') ||
|
|
432
|
+
includes('capture list') ||
|
|
430
433
|
includes('avoid retain cycles') ||
|
|
431
434
|
includes('evitar retain cycles')
|
|
432
435
|
) {
|
|
433
|
-
return 'skills.ios.guideline.ios.
|
|
436
|
+
return 'skills.ios.guideline.ios.evitar-retain-cycles-especialmente-en-closures-delegates';
|
|
434
437
|
}
|
|
435
438
|
if (
|
|
436
439
|
includes('mixing legacy xctest style') ||
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pumuki",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.208",
|
|
4
4
|
"description": "Enterprise-grade AST Intelligence System with multi-platform support (iOS, Android, Backend, Frontend) and Feature-First + DDD + Clean Architecture enforcement. Includes dynamic violations API for intelligent querying.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
package/skills.lock.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "1.0",
|
|
3
3
|
"compilerVersion": "1.0.0",
|
|
4
|
-
"generatedAt": "2026-05-13T12:
|
|
4
|
+
"generatedAt": "2026-05-13T12:37:42.811Z",
|
|
5
5
|
"bundles": [
|
|
6
6
|
{
|
|
7
7
|
"name": "android-guidelines",
|
|
@@ -5764,7 +5764,7 @@
|
|
|
5764
5764
|
"name": "ios-guidelines",
|
|
5765
5765
|
"version": "1.0.0",
|
|
5766
5766
|
"source": "file:vendor/skills/ios-enterprise-rules/SKILL.md",
|
|
5767
|
-
"hash": "
|
|
5767
|
+
"hash": "32c74edc740622834bf48fa060ebc04f8d5ee0c826e9a6dd48a068212dfc2552",
|
|
5768
5768
|
"rules": [
|
|
5769
5769
|
{
|
|
5770
5770
|
"id": "skills.ios.guideline.ios.accessibility-identifiers-para-localizar-elementos",
|
|
@@ -6042,18 +6042,6 @@
|
|
|
6042
6042
|
"evaluationMode": "DECLARATIVE",
|
|
6043
6043
|
"origin": "core"
|
|
6044
6044
|
},
|
|
6045
|
-
{
|
|
6046
|
-
"id": "skills.ios.guideline.ios.capture-lists-capturar-valores-no-referencias",
|
|
6047
|
-
"description": "Capture lists - Capturar valores, no referencias",
|
|
6048
|
-
"severity": "WARN",
|
|
6049
|
-
"platform": "ios",
|
|
6050
|
-
"sourceSkill": "ios-guidelines",
|
|
6051
|
-
"sourcePath": "vendor/skills/ios-enterprise-rules/SKILL.md",
|
|
6052
|
-
"confidence": "MEDIUM",
|
|
6053
|
-
"locked": true,
|
|
6054
|
-
"evaluationMode": "DECLARATIVE",
|
|
6055
|
-
"origin": "core"
|
|
6056
|
-
},
|
|
6057
6045
|
{
|
|
6058
6046
|
"id": "skills.ios.guideline.ios.carthage-prohibido",
|
|
6059
6047
|
"description": "Carthage - Prohibido",
|
|
@@ -6510,6 +6498,18 @@
|
|
|
6510
6498
|
"evaluationMode": "DECLARATIVE",
|
|
6511
6499
|
"origin": "core"
|
|
6512
6500
|
},
|
|
6501
|
+
{
|
|
6502
|
+
"id": "skills.ios.guideline.ios.evitar-retain-cycles-especialmente-en-closures-delegates",
|
|
6503
|
+
"description": "[weak self] - En closures que pueden outlive self",
|
|
6504
|
+
"severity": "WARN",
|
|
6505
|
+
"platform": "ios",
|
|
6506
|
+
"sourceSkill": "ios-guidelines",
|
|
6507
|
+
"sourcePath": "vendor/skills/ios-enterprise-rules/SKILL.md",
|
|
6508
|
+
"confidence": "MEDIUM",
|
|
6509
|
+
"locked": true,
|
|
6510
|
+
"evaluationMode": "AUTO",
|
|
6511
|
+
"origin": "core"
|
|
6512
|
+
},
|
|
6513
6513
|
{
|
|
6514
6514
|
"id": "skills.ios.guideline.ios.expect-y-require-assertions-de-swift-testing",
|
|
6515
6515
|
"description": "#expect y #require - Assertions de Swift Testing",
|
|
@@ -8239,18 +8239,6 @@
|
|
|
8239
8239
|
"evaluationMode": "DECLARATIVE",
|
|
8240
8240
|
"origin": "core"
|
|
8241
8241
|
},
|
|
8242
|
-
{
|
|
8243
|
-
"id": "skills.ios.guideline.ios.weak-self-en-closures-que-pueden-outlive-self",
|
|
8244
|
-
"description": "[weak self] - En closures que pueden outlive self",
|
|
8245
|
-
"severity": "WARN",
|
|
8246
|
-
"platform": "ios",
|
|
8247
|
-
"sourceSkill": "ios-guidelines",
|
|
8248
|
-
"sourcePath": "vendor/skills/ios-enterprise-rules/SKILL.md",
|
|
8249
|
-
"confidence": "MEDIUM",
|
|
8250
|
-
"locked": true,
|
|
8251
|
-
"evaluationMode": "DECLARATIVE",
|
|
8252
|
-
"origin": "core"
|
|
8253
|
-
},
|
|
8254
8242
|
{
|
|
8255
8243
|
"id": "skills.ios.guideline.ios.xcode-usar-la-u-ltima-versio-n-estable-disponible",
|
|
8256
8244
|
"description": "Xcode: usar la última versión estable disponible",
|