Skip to content

Commit eb412d7

Browse files
author
Seth Rait
committed
check caller onboarded
1 parent f729353 commit eb412d7

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

lib/container-mapping.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,7 @@ class ContainerMapping {
9898
if (!bearerToken) {
9999
throw new Error("Empty OIDC token received");
100100
}
101-
var callerIsOnboarded = yield this.checkCallerIsCustomer(bearerToken, sendReportRetryCount)
102-
.catch((error) => {
103-
core.info(`CAUGHT: ${error}`);
104-
return;
105-
});
101+
var callerIsOnboarded = yield this.checkCallerIsCustomer(bearerToken, sendReportRetryCount);
106102
if (!callerIsOnboarded) {
107103
core.info("Client is not onboarded to Defender for DevOps. Skipping container mapping workload.");
108104
return;
@@ -219,7 +215,7 @@ class ContainerMapping {
219215
return false;
220216
}
221217
else {
222-
core.info(`Unexpected status code: ${statusCode}`);
218+
core.debug(`Unexpected status code: ${statusCode}`);
223219
if (retryCount == 0) {
224220
return false;
225221
}
@@ -262,9 +258,10 @@ class ContainerMapping {
262258
core.info(`Status code: ${res.statusCode} ${res.statusMessage}`);
263259
resolve(res.statusCode);
264260
});
261+
res.on('data', function (d) {
262+
});
265263
});
266264
req.on('error', (error) => {
267-
core.info(`Error in _checkCallerIsCustomer: ${error.name}, ${error.message}`);
268265
reject(new Error(`Error calling url: ${error}`));
269266
});
270267
req.end();

src/container-mapping.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,7 @@ export class ContainerMapping implements IMicrosoftSecurityDevOps {
9898
}
9999

100100
// Don't run the container mapping workload if this caller isn't an active customer.
101-
var callerIsOnboarded: boolean | void = await this.checkCallerIsCustomer(bearerToken, sendReportRetryCount)
102-
.catch((error) => {
103-
core.info(`CAUGHT: ${error}`);
104-
return;
105-
});
101+
var callerIsOnboarded: boolean = await this.checkCallerIsCustomer(bearerToken, sendReportRetryCount);
106102
if (!callerIsOnboarded) {
107103
core.info("Client is not onboarded to Defender for DevOps. Skipping container mapping workload.")
108104
return;
@@ -238,7 +234,7 @@ export class ContainerMapping implements IMicrosoftSecurityDevOps {
238234
} else if (statusCode == 403) {// Status 'Forbidden' means caller is not a customer.
239235
return false;
240236
} else {
241-
core.info(`Unexpected status code: ${statusCode}`); // TODO: core.debug
237+
core.debug(`Unexpected status code: ${statusCode}`);
242238
if (retryCount == 0) {
243239
return false;
244240
} else {
@@ -277,16 +273,14 @@ export class ContainerMapping implements IMicrosoftSecurityDevOps {
277273

278274
res.on('end', () => {
279275
core.debug('API calls finished. Time taken: ' + (new Date().getMilliseconds() - apiTime) + "ms");
280-
core.info(`Status code: ${res.statusCode} ${res.statusMessage}`); // TODO
276+
core.info(`Status code: ${res.statusCode} ${res.statusMessage}`);
281277
resolve(res.statusCode);
282278
});
283-
// res.on('data', function(d) {
284-
// core.info(`data: ${d}`);
285-
// });
279+
res.on('data', function(d) {
280+
});
286281
});
287282

288283
req.on('error', (error) => {
289-
core.info(`Error in _checkCallerIsCustomer: ${error.name}, ${error.message}`); // TODO
290284
reject(new Error(`Error calling url: ${error}`));
291285
});
292286

0 commit comments

Comments
 (0)