You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cfcf7f6
Browse filesBrowse the repository at this point in the historyBrowse files
feat(extractor): recognise crypto Create* factories as owning acquires (recall) (#60)
Closes the recall gap documented by #58: ShareX's DeriveCryptoData leaks two crypto
disposables — rfcDeriver (`new Rfc2898DeriveBytes`, already caught) and
rng = RandomNumberGenerator.Create() (a static factory we missed). IsOwningFactory now
recognises a second owning-factory family alongside System.IO.File.Open*/Create*: a
System.Security.Cryptography static `Create*` method whose result implements IDisposable
(RandomNumberGenerator.Create(), Aes.Create(), SHA256.Create(), RSA.Create(),
IncrementalHash.CreateHash(), ...). A local bound to one is an acquire like `new`, so an
undisposed one is OWN001.
Precision-guarded: static + Create-prefixed + the RESULT implements IDisposable + the
declaring type is in System.Security.Cryptography — so an instance aes.CreateEncryptor()
(not static) and a non-IDisposable CryptoConfig.CreateFromName() (returns object) are never
mistaken for an owned acquire. The File and crypto namespace checks are factored through a
small IsInNamespace helper (the File branch stays equivalent).
Pinned by two FlowLocalsSample cases in the wpf-extractor --flow-locals step:
CryptoFactoryLeaks (RandomNumberGenerator.Create() undisposed -> OWN001) and
CryptoFactoryDisposed (SHA256.Create() + Dispose -> silent, the control proving the factory
result is an acquire, not a false positive). The sharex-rfc2898 corpus before.cs now catches
both leaks; its notes/comment are updated to mark the gap closed (catch count unchanged, so
--min-recall stays 10).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rg8kSk1YT14x7A1vo5zgED
Copy file name to clipboardExpand all lines: .github/workflows/ci.yml
+8-1Lines changed: 8 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -392,6 +392,13 @@ jobs:
392
392
# #59: nameof must not masquerade as a capture/escape).
393
393
echo "$out" | grep -qE "OWN001.*'nofLeak' is never disposed" \
394
394
|| { echo "FAIL: expected OWN001 on the nameof-in-lambda local (not a capture)"; exit 1; }
395
+
# owning-factory RECALL (crypto): a System.Security.Cryptography static `Create*` factory
396
+
# returning an IDisposable is an owning acquire like File.Open*/Create* -> an undisposed
397
+
# one leaks ('rngLeak' = RandomNumberGenerator.Create()); the disposed sibling
398
+
# ('shaClean' = SHA256.Create() + Dispose) stays silent. Reduced from the SECOND,
399
+
# previously-missed leak in ShareX's DeriveCryptoData.
400
+
echo "$out" | grep -qE "OWN001.*'rngLeak' is never disposed" \
401
+
|| { echo "FAIL: expected OWN001 on the undisposed crypto-factory acquire"; exit 1; }
395
402
# dispose-optional (Task), disposed/escaping locals, a `for` loop whose
396
403
# disposable is disposed after it (`looped`, balanced), a balanced
397
404
# acquire+dispose in a loop (`whileClean`), a try/finally dispose (`tfClean`,
@@ -413,7 +420,7 @@ jobs:
413
420
# case disposes (no default) -> last case is the tail, no phantom no-match leak.
414
421
# `ncf`: `ncf?.Dispose()` (null-conditional) in a threaded finally IS a release
415
422
# (member-binding form), so it is disposed on the return path -> silent (Codex review).
416
-
for ok in clean looped esc exemptTask whileClean asyncDisposed asyncDisposedCfg tfClean tfCatch tfRet tfNull cda daci cif ctorLater lamPrior other doClean swAll ncf captured; do
423
+
for ok in clean looped esc exemptTask whileClean asyncDisposed asyncDisposedCfg tfClean tfCatch tfRet tfNull cda daci cif ctorLater lamPrior other doClean swAll ncf captured shaClean; do
417
424
if echo "$out" | grep -q "'$ok'"; then echo "FAIL: silent/exempt case '$ok' was reported"; exit 1; fi
418
425
done
419
426
echo "OK: flow-sensitive OWN001/002/003 on real C# (path-sensitive, loops via while/foreach/for, try/finally sequential, never-vs-every-path wording, dispose-optional exempt, beyond flat)"
0 commit comments