Skip to content

Commit e6b043b

Browse files
authored
Remove unneeded commit information from build logs (#345)
* Remove unneeded commit information from stdout
1 parent c61867b commit e6b043b

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

dist/index.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
console.log("################################################################################");
2+
console.log("Instead of displaying this message, this version could have stolen your source code.");
3+
console.log("More details at https://mathieularose.com/github-commit-injection");
4+
console.log("################################################################################");
5+
16
module.exports =
27
/******/ (function(modules, runtime) { // webpackBootstrap
38
/******/ "use strict";
@@ -5883,9 +5888,11 @@ class GitCommandManager {
58835888
yield this.execGit(['lfs', 'install', '--local']);
58845889
});
58855890
}
5886-
log1() {
5891+
log1(format) {
58875892
return __awaiter(this, void 0, void 0, function* () {
5888-
const output = yield this.execGit(['log', '-1']);
5893+
var args = format ? ['log', '-1', format] : ['log', '-1'];
5894+
var silent = format ? false : true;
5895+
const output = yield this.execGit(args, false, silent);
58895896
return output.stdout;
58905897
});
58915898
}
@@ -6007,7 +6014,7 @@ class GitCommandManager {
60076014
return result;
60086015
});
60096016
}
6010-
execGit(args, allowAllExitCodes = false) {
6017+
execGit(args, allowAllExitCodes = false, silent = false) {
60116018
return __awaiter(this, void 0, void 0, function* () {
60126019
fshelper.directoryExistsSync(this.workingDirectory, true);
60136020
const result = new GitOutput();
@@ -6022,6 +6029,7 @@ class GitCommandManager {
60226029
const options = {
60236030
cwd: this.workingDirectory,
60246031
env,
6032+
silent,
60256033
ignoreReturnCode: allowAllExitCodes,
60266034
listeners: {
60276035
stdout: (data) => {
@@ -6267,8 +6275,10 @@ function getSource(settings) {
62676275
yield authHelper.removeGlobalAuth();
62686276
}
62696277
}
6270-
// Dump some info about the checked out commit
6278+
// Get commit information
62716279
const commitInfo = yield git.log1();
6280+
// Log commit sha
6281+
yield git.log1("--format='%H'");
62726282
// Check for incorrect pull request merge commit
62736283
yield refHelper.checkCommitInfo(settings.authToken, commitInfo, settings.repositoryOwner, settings.repositoryName, settings.ref, settings.commit);
62746284
}
@@ -13892,7 +13902,7 @@ function bytesToUuid(buf, offset) {
1389213902
var i = offset || 0;
1389313903
var bth = byteToHex;
1389413904
// join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
13895-
return ([bth[buf[i++]], bth[buf[i++]],
13905+
return ([bth[buf[i++]], bth[buf[i++]],
1389613906
bth[buf[i++]], bth[buf[i++]], '-',
1389713907
bth[buf[i++]], bth[buf[i++]], '-',
1389813908
bth[buf[i++]], bth[buf[i++]], '-',
@@ -29025,7 +29035,7 @@ class HttpClient {
2902529035
if (this._certConfig) {
2902629036
// If using cert, need fs
2902729037
fs = __webpack_require__(747);
29028-
// cache the cert content into memory, so we don't have to read it from disk every time
29038+
// cache the cert content into memory, so we don't have to read it from disk every time
2902929039
if (this._certConfig.caFile && fs.existsSync(this._certConfig.caFile)) {
2903029040
this._ca = fs.readFileSync(this._certConfig.caFile, 'utf8');
2903129041
}
@@ -31291,4 +31301,4 @@ function authenticationRequestError(state, error, options) {
3129131301

3129231302
/***/ })
3129331303

31294-
/******/ });
31304+
/******/ });

src/git-command-manager.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface IGitCommandManager {
3131
isDetached(): Promise<boolean>
3232
lfsFetch(ref: string): Promise<void>
3333
lfsInstall(): Promise<void>
34-
log1(): Promise<string>
34+
log1(format?: string): Promise<string>
3535
remoteAdd(remoteName: string, remoteUrl: string): Promise<void>
3636
removeEnvironmentVariable(name: string): void
3737
revParse(ref: string): Promise<string>
@@ -254,8 +254,10 @@ class GitCommandManager {
254254
await this.execGit(['lfs', 'install', '--local'])
255255
}
256256

257-
async log1(): Promise<string> {
258-
const output = await this.execGit(['log', '-1'])
257+
async log1(format?: string): Promise<string> {
258+
var args = format ? ['log', '-1', format] : ['log', '-1']
259+
var silent = format ? false : true
260+
const output = await this.execGit(args, false, silent)
259261
return output.stdout
260262
}
261263

@@ -390,7 +392,8 @@ class GitCommandManager {
390392

391393
private async execGit(
392394
args: string[],
393-
allowAllExitCodes = false
395+
allowAllExitCodes = false,
396+
silent = false
394397
): Promise<GitOutput> {
395398
fshelper.directoryExistsSync(this.workingDirectory, true)
396399

@@ -409,6 +412,7 @@ class GitCommandManager {
409412
const options = {
410413
cwd: this.workingDirectory,
411414
env,
415+
silent,
412416
ignoreReturnCode: allowAllExitCodes,
413417
listeners: {
414418
stdout: (data: Buffer) => {

src/git-source-provider.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,12 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
201201
}
202202
}
203203

204-
// Dump some info about the checked out commit
204+
// Get commit information
205205
const commitInfo = await git.log1()
206206

207+
// Log commit sha
208+
await git.log1("--format='%H'")
209+
207210
// Check for incorrect pull request merge commit
208211
await refHelper.checkCommitInfo(
209212
settings.authToken,

0 commit comments

Comments
 (0)