@alertlogic/al-collector-js 3.0.16 → 3.0.18

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.
package/azcollectc.js CHANGED
@@ -156,6 +156,45 @@ class AzcollectC extends AlServiceC {
156
156
  break;
157
157
  }
158
158
  }
159
+
160
+ /**
161
+ * Returns the collector configuration containing {pawsCreds, pawsAimsCreds, pawsConfig}.
162
+ * @param {object} getConfigInput - Required input object; `collectorId` is mandatory.
163
+ * @returns {object} Collector configuration object.
164
+ */
165
+ getCollectorConfig(getConfigInput) {
166
+ return this.get(`/paws/config/` +
167
+ `${getConfigInput.collectorId}`, {});
168
+ }
169
+ /**
170
+ * Send the data to azcollect to update the collector configuration.
171
+ * @param {*} putConfigInput - Required input object; `collectorId` is mandatory and `compressed` is optional.
172
+ * @param {*} updatedStateBody - Json object to be send to azcollect
173
+ * @returns {*} Response from Azcollect after updating the configuration
174
+ */
175
+ updateCollectorStateConfig(putConfigInput, updatedStateBody) {
176
+ const postConfigUrl = `/paws/config/` +
177
+ `${putConfigInput.collectorId}`;
178
+ const compressed = putConfigInput.compressed ? putConfigInput.compressed : false;
179
+
180
+ if (compressed) {
181
+ var data = zlib.deflateSync(JSON.stringify(updatedStateBody));
182
+ let payload = {
183
+ json: false,
184
+ headers: {
185
+ 'Content-Encoding': 'deflate',
186
+ 'Content-Length': Buffer.byteLength(data)
187
+ },
188
+ body: data
189
+ };
190
+ return this.put(postConfigUrl, payload);
191
+ } else {
192
+ let payload = {
193
+ body: updatedStateBody
194
+ };
195
+ return this.put(postConfigUrl, payload);
196
+ }
197
+ }
159
198
  }
160
199
 
161
200
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alertlogic/al-collector-js",
3
- "version": "3.0.16",
3
+ "version": "3.0.18",
4
4
  "license": "MIT",
5
5
  "description": "Alert Logic Collector Common Library",
6
6
  "repository": {
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "async": "3.2.6",
34
- "axios": "^1.11.0",
34
+ "axios": "^1.12.2",
35
35
  "debug": "^4.4.1",
36
36
  "lodash.clonedeep": "^4.5.0",
37
37
  "lodash.filter": "^4.6.0",
package/test/al_mock.js CHANGED
@@ -163,6 +163,29 @@ const SERVER_ERROR_500 = {
163
163
  statusCode: 500,
164
164
  message: "Internal Server Error"
165
165
  };
166
+
167
+ const COLLECT_CONFIG = {
168
+ "pawsCreds": {
169
+ "clientId": "b322e5cc-fdfdfdfd-97445373db77",
170
+ "clientSecret": "Cv=wJJaeNm_TVVsbndbsd_[100",
171
+ "applicationId": "cdfc67dd-1c13-4487-af02-80dba2236485"
172
+ },
173
+ "pawsAimsCreds": {
174
+ "aimsAccessKey": "fsdfgfdgfg",
175
+ "aimsSecretKey": "461a11182gfgfgfgfdgfgee0bdf0a9c8b58bf492014e77f39",
176
+ "customerId": 2,
177
+ "alertLogicApplicationId": "o365",
178
+ "collectorId": "C3646C47-GDFGGF-45AA-B61D-6967E245F16G"
179
+ },
180
+ "pawsConfig": {
181
+ "stream": "Audit.AzureActiveDirectory",
182
+ "since": "2025-06-09T10:20:09.097Z",
183
+ "until": "2025-06-09T11:20:09.097Z",
184
+ "pollIntervalSec": 1,
185
+ "collectorType": "o365"
186
+ }
187
+ };
188
+
166
189
  function gen_auth_response() {
167
190
  return {
168
191
  authentication : {
@@ -193,6 +216,7 @@ module.exports = {
193
216
  SEND_COLLECTOR_STATUS_BODY_DATA: SEND_COLLECTOR_STATUS_BODY_DATA,
194
217
  COLLECTOR_STATUS_API: COLLECTOR_STATUS_API,
195
218
  SERVER_ERROR_500: SERVER_ERROR_500,
219
+ COLLECT_CONFIG: COLLECT_CONFIG,
196
220
 
197
221
  gen_auth_response : gen_auth_response
198
222
  };
@@ -19,8 +19,10 @@ describe('Unit Tests', function() {
19
19
 
20
20
  describe('AzcollectC AWS functions', function() {
21
21
  var fakePost;
22
+ var fakePut;
22
23
  var fakeDel;
23
24
  var fakeAuth;
25
+ var fakeGet;
24
26
 
25
27
  beforeEach(function() {
26
28
  fakeAuth = sinon.stub(AimsC.prototype, 'authenticate').callsFake(
@@ -37,6 +39,20 @@ describe('Unit Tests', function() {
37
39
  });
38
40
  });
39
41
 
42
+ fakePut = sinon.stub(AzcollectC.prototype, 'put').callsFake(
43
+ function fakeFn(path, options) {
44
+ return new Promise(function(resolve, reject) {
45
+ resolve('ok');
46
+ });
47
+ });
48
+
49
+ fakeGet = sinon.stub(AzcollectC.prototype, 'get').callsFake(
50
+ function fakeFn(path, options) {
51
+ return new Promise(function (resolve, reject) {
52
+ resolve('ok');
53
+ });
54
+ });
55
+
40
56
  fakeDel = sinon.stub(AzcollectC.prototype, 'deleteRequest').callsFake(
41
57
  function fakeFn(path, options) {
42
58
  return new Promise(function(resolve, reject) {
@@ -49,6 +65,8 @@ describe('Unit Tests', function() {
49
65
  fakePost.restore();
50
66
  fakeDel.restore();
51
67
  fakeAuth.restore();
68
+ fakeGet.restore();
69
+ fakePut.restore();
52
70
  fs.unlink(m_alMock.CACHE_FILENAME, function(err){
53
71
  done();
54
72
  });
@@ -190,6 +208,29 @@ describe('Unit Tests', function() {
190
208
  });
191
209
  });
192
210
 
211
+ it('AWS get collector config', function (done) {
212
+ var aimsc = new AimsC(m_alMock.AL_API, m_alMock.AIMS_CREDS);
213
+ var azc = new AzcollectC(m_alMock.INGEST_ENDPOINT, aimsc, 'aws', 'o365');
214
+ azc.getCollectorConfig({ collectorId: 'C3646C47-GDFGGF-45AA-B61D-6967E245F16G' }).then(resp => {
215
+ sinon.assert.calledWith(fakeGet,
216
+ '/paws/config/C3646C47-GDFGGF-45AA-B61D-6967E245F16G', {}
217
+ );
218
+ done();
219
+ });
220
+ });
221
+
222
+ it('AWS update collector config', function (done) {
223
+ var aimsc = new AimsC(m_alMock.AL_API, m_alMock.AIMS_CREDS);
224
+ var azc = new AzcollectC(m_alMock.INGEST_ENDPOINT, aimsc, 'aws', 'o365');
225
+ azc.updateCollectorStateConfig({ collectorId: 'C3646C47-GDFGGF-45AA-B61D-6967E245F16G' }, m_alMock.COLLECT_CONFIG).then(resp => {
226
+ sinon.assert.calledWith(fakePut,
227
+ '/paws/config/C3646C47-GDFGGF-45AA-B61D-6967E245F16G',
228
+ { body: m_alMock.COLLECT_CONFIG }
229
+ );
230
+ done();
231
+ });
232
+ });
233
+
193
234
  });
194
235
 
195
236
  describe('AzcollectC Azure functions', function() {