snyk 1.880.0 → 1.881.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2631,8 +2631,25 @@ const request_1 = __webpack_require__(52050);
2631
2631
  const api_token_1 = __webpack_require__(95181);
2632
2632
  const envelope_formatters_1 = __webpack_require__(88784);
2633
2633
  const authentication_failed_error_1 = __webpack_require__(23770);
2634
+ const git_1 = __webpack_require__(24850);
2635
+ const analytics = __webpack_require__(82744);
2636
+ const dev_count_analysis_1 = __webpack_require__(73898);
2637
+ const Debug = __webpack_require__(15158);
2638
+ const debug = Debug('iac-cli-share-results');
2634
2639
  async function shareResults(results, policy) {
2635
- const scanResults = results.map((result) => envelope_formatters_1.convertIacResultToScanResult(result, policy));
2640
+ const gitTarget = (await git_1.getInfo(false));
2641
+ const scanResults = results.map((result) => envelope_formatters_1.convertIacResultToScanResult(result, policy, gitTarget));
2642
+ let contributors = [];
2643
+ if (gitTarget.remoteUrl) {
2644
+ if (analytics.allowAnalytics()) {
2645
+ try {
2646
+ contributors = await dev_count_analysis_1.getContributors();
2647
+ }
2648
+ catch (err) {
2649
+ debug('error getting repo contributors', err);
2650
+ }
2651
+ }
2652
+ }
2636
2653
  const { res, body } = await request_1.makeRequest({
2637
2654
  method: 'POST',
2638
2655
  url: `${config_1.default.API}/iac-cli-share-results`,
@@ -2640,7 +2657,10 @@ async function shareResults(results, policy) {
2640
2657
  headers: {
2641
2658
  authorization: api_token_1.getAuthHeader(),
2642
2659
  },
2643
- body: scanResults,
2660
+ body: {
2661
+ scanResults,
2662
+ contributors,
2663
+ },
2644
2664
  });
2645
2665
  if (res.statusCode === 401) {
2646
2666
  throw authentication_failed_error_1.AuthFailedError();
@@ -2687,7 +2707,7 @@ exports.TEST_SUPPORTED_IAC_PROJECTS = [
2687
2707
 
2688
2708
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2689
2709
  exports.convertIacResultToScanResult = void 0;
2690
- function convertIacResultToScanResult(iacResult, policy) {
2710
+ function convertIacResultToScanResult(iacResult, policy, gitTarget) {
2691
2711
  var _a;
2692
2712
  return {
2693
2713
  identity: {
@@ -2702,7 +2722,9 @@ function convertIacResultToScanResult(iacResult, policy) {
2702
2722
  };
2703
2723
  }),
2704
2724
  name: iacResult.projectName,
2705
- target: { name: iacResult.projectName },
2725
+ target: Object.keys(gitTarget).length === 0
2726
+ ? { name: iacResult.projectName }
2727
+ : { ...gitTarget, branch: 'master' },
2706
2728
  policy: (_a = policy === null || policy === void 0 ? void 0 : policy.toString()) !== null && _a !== void 0 ? _a : '',
2707
2729
  };
2708
2730
  }