@contrail/flexplm 1.7.4-alpha.8ba0056 → 1.7.4-alpha.90ac7f4

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.
@@ -493,18 +493,15 @@ class BaseProcessPublishAssortment {
493
493
  const item = aItem?.item;
494
494
  const itemId = item?.id;
495
495
  const itemFamilyId = item?.itemFamilyId;
496
- // ET-243: meets criteria is separated out for itemId and familyId separately
497
496
  if (meetsCriteria) {
498
497
  releasedForDevelopmentItemIds.push(itemId);
499
- }
500
- if (!itemFamilySet.has(itemFamilyId) && itemId !== itemFamilyId) {
501
- const familyItem = item?.itemFamily;
502
- if (familyItem) {
503
- if (this.meetsCriteria({ item: familyItem })
504
- && !releasedForDevelopmentItemIds.includes(itemFamilyId)) {
498
+ if (!itemFamilySet.has(itemFamilyId) && itemId !== itemFamilyId) {
499
+ const familyItem = item?.itemFamily;
500
+ const familyItemMeetsCriteria = this.meetsCriteria({ item: familyItem });
501
+ if (familyItemMeetsCriteria) {
505
502
  releasedForDevelopmentItemIds.push(itemFamilyId);
506
503
  }
507
- itemFamilySet.add(itemFamilyId); // only mark resolved when we had data to judge
504
+ itemFamilySet.add(itemFamilyId);
508
505
  }
509
506
  }
510
507
  }
@@ -515,19 +512,18 @@ class BaseProcessPublishAssortment {
515
512
  const itemFamilyId = item?.itemFamilyId;
516
513
  if (meetsCriteria) {
517
514
  releasedForDevelopmentItemIds.push(itemId);
518
- }
519
- if (!itemFamilySet.has(itemFamilyId) && itemId !== itemFamilyId) {
520
- const familyItem = item?.itemFamily;
521
- if (familyItem) {
522
- const familyItemMeetsCriteria = this.meetsCriteria({ item: familyItem });
523
- if (familyItemMeetsCriteria
524
- && !releasedForDevelopmentItemIds.includes(itemFamilyId)) {
525
- releasedForDevelopmentItemIds.push(itemFamilyId);
515
+ if (!itemFamilySet.has(itemFamilyId) && itemId !== itemFamilyId) {
516
+ const familyItem = item?.itemFamily;
517
+ if (familyItem) {
518
+ const familyItemMeetsCriteria = this.meetsCriteria({ item: familyItem });
519
+ if (familyItemMeetsCriteria) {
520
+ releasedForDevelopmentItemIds.push(itemFamilyId);
521
+ }
522
+ itemFamilySet.add(itemFamilyId);
523
+ }
524
+ else {
525
+ itemFamilySet.add(itemFamilyId);
526
526
  }
527
- itemFamilySet.add(itemFamilyId);
528
- }
529
- else {
530
- itemFamilySet.add(itemFamilyId);
531
527
  }
532
528
  }
533
529
  }
@@ -63,7 +63,6 @@ class FlexPLMConnect {
63
63
  const nonce_key = body.items[0].attributes.nonce_key;
64
64
  const nonce = body.items[0].attributes.nonce;
65
65
  console.info('nonce_key: ' + nonce_key);
66
- console.info('nonce: ' + nonce);
67
66
  return {
68
67
  nonce_key,
69
68
  nonce
@@ -89,7 +88,10 @@ class FlexPLMConnect {
89
88
  console.info('Request:');
90
89
  console.info('vibeEventsURL: ' + vibeEventsURL);
91
90
  const logOptions = JSON.parse(JSON.stringify(xferOptions));
92
- logOptions['headers']['Authorization'] = logOptions?.headers?.Authorization.substring(0, 9);
91
+ if (logOptions?.headers?.Authorization)
92
+ logOptions.headers.Authorization = logOptions?.headers?.Authorization.substring(0, 9);
93
+ if (csrf?.nonce_key)
94
+ logOptions.headers[csrf.nonce_key] = csrf.nonce ? `***masked(length:${csrf.nonce.length})***` : '***masked(empty)***';
93
95
  console.info('csrfOptions: ' + JSON.stringify(logOptions));
94
96
  console.info('Making call to xfer data to FlexPLM');
95
97
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const flexplm_connect_1 = require("./flexplm-connect");
4
+ const app_framework_1 = require("@contrail/app-framework");
4
5
  const mockJsonData = { items: [{ id: '123', name: 'test' }] };
5
6
  const mockResponse = (status, json = mockJsonData) => ({
6
7
  status,
@@ -87,3 +88,36 @@ describe('FlexPLMConnect.getRequest', () => {
87
88
  await expect(connect.getRequest()).rejects.toThrow('Error getting json data from FlexPLM: Invalid JSON');
88
89
  });
89
90
  });
91
+ describe('FlexPLMConnect.sendRequest', () => {
92
+ it('should mask csrf nonce value in logged request options', async () => {
93
+ const loggerIsInfoOnSpy = jest.spyOn(app_framework_1.Logger, 'isInfoOn').mockReturnValue(true);
94
+ const consoleInfoSpy = jest.spyOn(console, 'info').mockImplementation();
95
+ const csrf = { nonce_key: 'CSRF_NONCE', nonce: 'raw-secret-nonce' };
96
+ const payload = { id: '123' };
97
+ const connect = new flexplm_connect_1.FlexPLMConnect(createConfig());
98
+ await connect.sendRequest(csrf, payload);
99
+ const csrfOptionsLogMessages = consoleInfoSpy.mock.calls
100
+ .map(([message]) => String(message ?? ''))
101
+ .filter(message => message.startsWith('csrfOptions: '));
102
+ const sendRequestOptionsLogMessage = csrfOptionsLogMessages.find(message => message.includes('"CSRF_NONCE":'));
103
+ expect(sendRequestOptionsLogMessage).toBeDefined();
104
+ expect(sendRequestOptionsLogMessage ?? '').not.toContain('raw-secret-nonce');
105
+ expect(sendRequestOptionsLogMessage ?? '').toContain(`"CSRF_NONCE":"***masked(length:${'raw-secret-nonce'.length})***"`);
106
+ loggerIsInfoOnSpy.mockRestore();
107
+ consoleInfoSpy.mockRestore();
108
+ });
109
+ it('should log masked(empty) when csrf nonce is empty', async () => {
110
+ const loggerIsInfoOnSpy = jest.spyOn(app_framework_1.Logger, 'isInfoOn').mockReturnValue(true);
111
+ const consoleInfoSpy = jest.spyOn(console, 'info').mockImplementation();
112
+ const csrf = { nonce_key: 'CSRF_NONCE', nonce: '' };
113
+ const connect = new flexplm_connect_1.FlexPLMConnect(createConfig());
114
+ await connect.sendRequest(csrf, { id: '123' });
115
+ const csrfOptionsLog = consoleInfoSpy.mock.calls
116
+ .map(([message]) => String(message ?? ''))
117
+ .find(message => message.includes('"CSRF_NONCE":'));
118
+ expect(csrfOptionsLog).toBeDefined();
119
+ expect(csrfOptionsLog ?? '').toContain('"CSRF_NONCE":"***masked(empty)***"');
120
+ loggerIsInfoOnSpy.mockRestore();
121
+ consoleInfoSpy.mockRestore();
122
+ });
123
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/flexplm",
3
- "version": "1.7.4-alpha.8ba0056",
3
+ "version": "1.7.4-alpha.90ac7f4",
4
4
  "description": "Library used for integration with flexplm.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",