Skip to content

Commit d459ba9

Browse files
committed
Remove unused field aggregation_stream - #53
1 parent 07ba8c9 commit d459ba9

File tree

7 files changed

+9
-64
lines changed

7 files changed

+9
-64
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/node/
33
/node_modules/
44

5-
# For the runtime dockre-compose
5+
# For the runtime docker-compose
66
/runtime/graylog/plugin/
77
/runtime/.env
88

src/main/java/com/airbus_cyber_security/graylog/events/config/LoggingAlertConfig.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public abstract class LoggingAlertConfig {
7777
public static LoggingAlertConfig create(
7878
@JsonProperty("separator") String separator,
7979
@JsonProperty("log_body") String logBody,
80-
@JsonProperty("aggregation_stream") String aggregationStream,
8180
@JsonProperty("aggregation_time") int aggregationTime,
8281
@JsonProperty("limit_overflow") int limitOverflow,
8382
@JsonProperty("field_alert_id") String fieldAlertId,
@@ -86,7 +85,6 @@ public static LoggingAlertConfig create(
8685
return builder()
8786
.accessSeparator(separator)
8887
.accessLogBody(logBody)
89-
.accessAggregationStream(aggregationStream)
9088
.accessAggregationTime(aggregationTime)
9189
.accessLimitOverflow(limitOverflow)
9290
.accessFieldAlertId(fieldAlertId)
@@ -99,7 +97,6 @@ public static LoggingAlertConfig createDefault() {
9997
return builder()
10098
.accessSeparator(" | ")
10199
.accessLogBody(BODY_TEMPLATE)
102-
.accessAggregationStream(DEFAULT_STREAM_ID)
103100
.accessAggregationTime(0)
104101
.accessLimitOverflow(0)
105102
.accessFieldAlertId(FIELD_ALERT_ID)
@@ -112,7 +109,6 @@ public static Builder builder() {
112109
return new AutoValue_LoggingAlertConfig.Builder();
113110
}
114111

115-
116112
public abstract Builder toBuilder();
117113

118114
@AutoValue.Builder

src/main/java/com/airbus_cyber_security/graylog/events/notifications/types/MessageBodyBuilder.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,10 @@ String getAlertIdentifier(int aggregationTime, LoggingAlertConfig generalConfig,
7373
String suffix = "-" + getHashFromString(events_definition_id + "-" + key);
7474

7575
String loggingAlertID = null;
76-
String aggregationStream = generalConfig.accessAggregationStream();
7776

78-
if (aggregationTime > 0 && aggregationStream != null && !aggregationStream.isEmpty()) {
77+
if (aggregationTime > 0) {
7978
String alertIdentifierFieldName = generalConfig.accessFieldAlertId();
80-
loggingAlertID = this.searches.getAggregationAlertIdentifier(aggregationTime, alertIdentifierFieldName, aggregationStream, suffix);
79+
loggingAlertID = this.searches.getAggregationAlertIdentifier(aggregationTime, alertIdentifierFieldName, suffix);
8180
}
8281

8382
if (loggingAlertID == null || loggingAlertID.isEmpty()) {

src/main/java/com/airbus_cyber_security/graylog/events/storage/MessagesSearches.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public MessagesSearches(Searches searches) {
4242
this.searches = searches;
4343
}
4444

45-
public String getAggregationAlertIdentifier(int aggregationTime, String alertIdentifierFieldName, String aggregationStream, String suffixID) {
45+
public String getAggregationAlertIdentifier(int aggregationTime, String alertIdentifierFieldName, String suffixID) {
4646
LOGGER.debug("Start of getAggregationAlertID...");
4747
try {
4848
RelativeRange relativeRange = RelativeRange.create(aggregationTime * 60);
@@ -52,12 +52,8 @@ public String getAggregationAlertIdentifier(int aggregationTime, String alertIde
5252
String query = messageFormat.format(new Object[]{alertIdentifierFieldName, suffixID});
5353
LOGGER.debug("Alert Query: {}", query);
5454

55-
// Add stream filter
56-
String filter = "streams:" + aggregationStream;
57-
LOGGER.debug("Alert filter: {}", filter);
58-
5955
// Execute query
60-
SearchResult result = this.searches.search(query, filter, range, 1, 0, new Sorting(Message.FIELD_TIMESTAMP, Sorting.Direction.DESC));
56+
SearchResult result = this.searches.search(query, range, 1, 0, new Sorting(Message.FIELD_TIMESTAMP, Sorting.Direction.DESC));
6157

6258
if (result != null) {
6359
LOGGER.debug("{} alert found", result.getResults().size());

src/test/java/com/airbus_cyber_security/graylog/events/notifications/types/MessageBodyBuilderTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class MessageBodyBuilderTest {
6666

6767
@Test
6868
public void testGetAlertIdentifierWithoutAlert() {
69-
when(messagesSearches.getAggregationAlertIdentifier(anyInt(), anyString(), anyString(), anyString())).thenReturn(null);
69+
when(messagesSearches.getAggregationAlertIdentifier(anyInt(), anyString(), anyString())).thenReturn(null);
7070
MessageBodyBuilder messageBodyBuilder = new MessageBodyBuilder(objectMapper, messagesSearches, notificationService);
7171

7272
LoggingAlertConfig generalConfig = buildLoggingAlertConfig();
@@ -79,7 +79,7 @@ public void testGetAlertIdentifierWithoutAlert() {
7979

8080
@Test
8181
public void testGetAlertIdentifierWithExistingAlert() {
82-
when(messagesSearches.getAggregationAlertIdentifier(anyInt(), anyString(), anyString(), anyString())).thenReturn(EVENT_ID_1);
82+
when(messagesSearches.getAggregationAlertIdentifier(anyInt(), anyString(), anyString())).thenReturn(EVENT_ID_1);
8383
MessageBodyBuilder messageBodyBuilder = new MessageBodyBuilder(objectMapper, messagesSearches, notificationService);
8484

8585
LoggingAlertConfig generalConfig = buildLoggingAlertConfig();
@@ -92,7 +92,6 @@ public void testGetAlertIdentifierWithExistingAlert() {
9292

9393
private static LoggingAlertConfig buildLoggingAlertConfig() {
9494
return LoggingAlertConfig.builder()
95-
.accessAggregationStream(AGGREGATION_STREAM)
9695
.accessFieldAlertId(ALERT_ID_FIELD)
9796
.accessSeparator("|")
9897
.accessLogBody("")

src/web/components/LoggingAlertConfig.jsx

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,8 @@
2323
// * components/pipelines/ProcessingTimelineComponent.tsx (with useEffect for StreamsStore
2424
// * threatintel/components/ThreatIntelPluginConfig.jsx
2525
import React, { useState } from 'react';
26-
import { useStore } from 'stores/connect';
27-
import { StreamsStore } from 'views/stores/StreamsStore';
28-
import { defaultCompare } from 'logic/DefaultCompare'
29-
3026
import { BootstrapModalForm, Button, Input } from 'components/bootstrap';
3127
import IfPermitted from 'components/common/IfPermitted';
32-
import Select from 'components/common/Select';
33-
import Spinner from 'components/common/Spinner';
3428

3529
export const DEFAULT_BODY_TEMPLATE = "type: alert" + "\n" +
3630
"id: ${logging_alert.id}" + "\n" +
@@ -52,10 +46,6 @@ const DEFAULT_CONFIG = {
5246
overflow_tag: 'LoggingOverflow',
5347
};
5448

55-
const _formatOption = (key, value) => {
56-
return { value: value, label: key };
57-
};
58-
5949
const _displayOptionalConfigurationValue = (value) => {
6050
if (!value) {
6151
return '[not set]';
@@ -66,7 +56,6 @@ const _displayOptionalConfigurationValue = (value) => {
6656
const LoggingAlertConfig = ({ config = DEFAULT_CONFIG, updateConfig }) => {
6757
const [nextConfiguration, setNextConfiguration] = useState(config);
6858
const [showModal, setShowModal] = useState(false);
69-
const { streams: streamList = [] } = useStore(StreamsStore);
7059

7160
const _openModal = () => {
7261
setShowModal(true);
@@ -76,16 +65,10 @@ const LoggingAlertConfig = ({ config = DEFAULT_CONFIG, updateConfig }) => {
7665
setShowModal(false);
7766
};
7867

79-
/* TODO is this necessary?
80-
useEffect(() => {
81-
setNextConfiguration({ ...config });
82-
}, [config]);
83-
*/
84-
8568
const _saveConfiguration = () => {
8669
updateConfig(nextConfiguration).then(() => {
8770
_closeModal();
88-
})
71+
});
8972
};
9073

9174
const _resetConfiguration = () => {
@@ -108,18 +91,6 @@ const LoggingAlertConfig = ({ config = DEFAULT_CONFIG, updateConfig }) => {
10891
};
10992
};
11093

111-
const _onAggregationStreamSelect = (value) => {
112-
_updateConfigurationField('aggregation_stream', value);
113-
};
114-
115-
if (!streamList) {
116-
return <Spinner />;
117-
}
118-
119-
const formattedStreams = streamList
120-
.map(stream => _formatOption(stream.title, stream.id))
121-
.sort((s1, s2) => defaultCompare(s1.label.toLowerCase(), s2.label.toLowerCase()));
122-
12394
return (
12495
<div>
12596
<h3>Logging Alert Notification Configuration</h3>
@@ -148,12 +119,6 @@ const LoggingAlertConfig = ({ config = DEFAULT_CONFIG, updateConfig }) => {
148119
{_displayOptionalConfigurationValue(config.aggregation_time)}
149120
</dd>
150121
</dl>
151-
<dl className="deflist">
152-
<dt>Alerts Stream: </dt>
153-
<dd>
154-
{_displayOptionalConfigurationValue(config.aggregation_stream)}
155-
</dd>
156-
</dl>
157122
<dl className="deflist">
158123
<dt>Alert ID Field: </dt>
159124
<dd>
@@ -220,16 +185,6 @@ const LoggingAlertConfig = ({ config = DEFAULT_CONFIG, updateConfig }) => {
220185
value={nextConfiguration.aggregation_time}
221186
onChange={_onUpdate('aggregation_time')}
222187
/>
223-
<Input id="aggregation-stream"
224-
label="Alerts Stream"
225-
help="Stream receiving the logged alerts that allows to aggregate alerts"
226-
name="aggregation_stream">
227-
<Select placeholder="Select the stream for the aggregation"
228-
options={formattedStreams}
229-
matchProp="value"
230-
value={nextConfiguration.aggregation_stream}
231-
onChange={_onAggregationStreamSelect} />
232-
</Input>
233188
<Input
234189
id="field_alert_id"
235190
type="text"

src/web/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export { DEFAULT_BODY_TEMPLATE } from 'components/LoggingAlertConfig';
3131

3232
const metadata = {
3333
name: packageJson.name
34-
}
34+
};
3535

3636
PluginStore.register(new PluginManifest(metadata, {
3737
systemConfigurations: [

0 commit comments

Comments
 (0)