re-enable "Linux packages_autoroller" (#130088)

Fixes https://github.com/flutter/flutter/issues/129744

This change:

1. re-enables the Linux packages_autoroller
2. ensures we redact the token from appearing in any logs (in local testing I realized some failure logs might still expose the token)

What actually fixed authentication however was creating and uploading a new GitHub personal access token, not this change.

It's currently failing post-submit because being marked `bringup` it is running in the try pool, which does not have permissions to access the cloud KMS. However, I ran a LED build in the prod pool that succeeded:

3a8f128c35/+/build.proto
This commit is contained in:
Christopher Fujino 2023-07-10 12:32:56 -07:00 committed by GitHub
parent 613bc89006
commit b89bfd8e37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 63 additions and 31 deletions

View File

@ -243,8 +243,6 @@ targets:
- name: Linux packages_autoroller - name: Linux packages_autoroller
presubmit: false presubmit: false
# TODO(fujino): https://github.com/flutter/flutter/issues/129744
bringup: true
recipe: pub_autoroller/pub_autoroller recipe: pub_autoroller/pub_autoroller
timeout: 30 timeout: 30
enabled_branches: enabled_branches:

View File

@ -80,7 +80,7 @@ ${parser.usage}
} }
final FrameworkRepository framework = FrameworkRepository( final FrameworkRepository framework = FrameworkRepository(
_localCheckouts, _localCheckouts(token),
mirrorRemote: Remote.mirror(mirrorUrl), mirrorRemote: Remote.mirror(mirrorUrl),
upstreamRemote: Remote.upstream(upstreamUrl), upstreamRemote: Remote.upstream(upstreamUrl),
); );
@ -106,7 +106,7 @@ String _parseOrgName(String remoteUrl) {
return match.group(1)!; return match.group(1)!;
} }
Checkouts get _localCheckouts { Checkouts _localCheckouts(String token) {
const FileSystem fileSystem = LocalFileSystem(); const FileSystem fileSystem = LocalFileSystem();
const ProcessManager processManager = LocalProcessManager(); const ProcessManager processManager = LocalProcessManager();
const Platform platform = LocalPlatform(); const Platform platform = LocalPlatform();
@ -114,6 +114,7 @@ Checkouts get _localCheckouts {
stdout: io.stdout, stdout: io.stdout,
stderr: io.stderr, stderr: io.stderr,
stdin: io.stdin, stdin: io.stdin,
filter: (String message) => message.replaceAll(token, '[GitHub TOKEN]'),
); );
return Checkouts( return Checkouts(
fileSystem: fileSystem, fileSystem: fileSystem,

View File

@ -70,6 +70,7 @@ class VerboseStdio extends Stdio {
required this.stdout, required this.stdout,
required this.stderr, required this.stderr,
required this.stdin, required this.stdin,
this.filter,
}); });
factory VerboseStdio.local() => VerboseStdio( factory VerboseStdio.local() => VerboseStdio(
@ -82,26 +83,50 @@ class VerboseStdio extends Stdio {
final io.Stdout stderr; final io.Stdout stderr;
final io.Stdin stdin; final io.Stdin stdin;
/// If provided, all messages will be passed through this function before being logged.
final String Function(String)? filter;
@override @override
void printError(String message) { void printError(String message) {
if (filter != null) {
message = filter!(message);
}
super.printError(message); super.printError(message);
stderr.writeln(message); stderr.writeln(message);
} }
@override
void printWarning(String message) {
if (filter != null) {
message = filter!(message);
}
super.printWarning(message);
stderr.writeln(message);
}
@override @override
void printStatus(String message) { void printStatus(String message) {
if (filter != null) {
message = filter!(message);
}
super.printStatus(message); super.printStatus(message);
stdout.writeln(message); stdout.writeln(message);
} }
@override @override
void printTrace(String message) { void printTrace(String message) {
if (filter != null) {
message = filter!(message);
}
super.printTrace(message); super.printTrace(message);
stdout.writeln(message); stdout.writeln(message);
} }
@override @override
void write(String message) { void write(String message) {
if (filter != null) {
message = filter!(message);
}
super.write(message); super.write(message);
stdout.write(message); stdout.write(message);
} }

View File

@ -6,6 +6,7 @@ import 'package:args/args.dart';
import 'package:conductor_core/src/stdio.dart'; import 'package:conductor_core/src/stdio.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
export 'package:test/fake.dart';
export 'package:test/test.dart' hide isInstanceOf; export 'package:test/test.dart' hide isInstanceOf;
export '../../../../packages/flutter_tools/test/src/fake_process_manager.dart'; export '../../../../packages/flutter_tools/test/src/fake_process_manager.dart';

View File

@ -1227,34 +1227,10 @@ void main() {
} }
/// A [Stdio] that will throw an exception if any of its methods are called. /// A [Stdio] that will throw an exception if any of its methods are called.
class _UnimplementedStdio implements Stdio { class _UnimplementedStdio extends Fake implements Stdio {
const _UnimplementedStdio(); _UnimplementedStdio();
static const _UnimplementedStdio _instance = _UnimplementedStdio(); static final _UnimplementedStdio instance = _UnimplementedStdio();
static _UnimplementedStdio get instance => _instance;
Never _throw() => throw Exception('Unimplemented!');
@override
List<String> get logs => _throw();
@override
void printError(String message) => _throw();
@override
void printWarning(String message) => _throw();
@override
void printStatus(String message) => _throw();
@override
void printTrace(String message) => _throw();
@override
void write(String message) => _throw();
@override
String readLineSync() => _throw();
} }
class _TestRepository extends Repository { class _TestRepository extends Repository {

View File

@ -512,4 +512,35 @@ void main() {
expect(processManager, hasNoRemainingExpectations); expect(processManager, hasNoRemainingExpectations);
}); });
}); });
test('VerboseStdio logger can filter out confidential pattern', () async {
const String token = 'secret';
const String replacement = 'replacement';
final VerboseStdio stdio = VerboseStdio(
stdin: _NoOpStdin(),
stderr: _NoOpStdout(),
stdout: _NoOpStdout(),
filter: (String msg) => msg.replaceAll(token, replacement),
);
stdio.printStatus('Hello');
expect(stdio.logs.last, '[status] Hello');
stdio.printStatus('Using $token');
expect(stdio.logs.last, '[status] Using $replacement');
stdio.printWarning('Using $token');
expect(stdio.logs.last, '[warning] Using $replacement');
stdio.printError('Using $token');
expect(stdio.logs.last, '[error] Using $replacement');
stdio.printTrace('Using $token');
expect(stdio.logs.last, '[trace] Using $replacement');
});
}
class _NoOpStdin extends Fake implements io.Stdin {}
class _NoOpStdout extends Fake implements io.Stdout {
@override
void writeln([Object? object]) {}
} }