Skip to content

Commit

Permalink
Defending pana log writes from cross-stream data. (#8069)
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos authored Oct 4, 2024
1 parent a2b74c7 commit 87022b5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/pub_worker/lib/src/analyze.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

import 'dart:async';
import 'dart:convert' show JsonUtf8Encoder, utf8;
import 'dart:convert' show JsonUtf8Encoder, LineSplitter, Utf8Decoder, utf8;
import 'dart:io'
show Directory, File, IOException, Platform, Process, ProcessSignal, gzip;
import 'dart:isolate' show Isolate;
Expand Down Expand Up @@ -152,8 +152,14 @@ Future<void> _analyzePackage(
await pana.stdin.close();

await Future.wait<void>([
pana.stderr.forEach(log.add),
pana.stdout.forEach(log.add),
pana.stderr
.transform(Utf8Decoder(allowMalformed: true))
.transform(LineSplitter())
.forEach(log.writeln),
pana.stdout
.transform(Utf8Decoder(allowMalformed: true))
.transform(LineSplitter())
.forEach(log.writeln),
pana.exitOrTimeout(_panaTimeout, () {
log.writeln('TIMEOUT: pana sending SIGTERM/SIGKILL');
}),
Expand Down

0 comments on commit 87022b5

Please sign in to comment.