Skip to content

Commit e0e83ac

Browse files
Onboards to centralized resource access control for detectors and forecasters (#1533)
* Onboards to the auto authz for Resource requests Signed-off-by: Darshit Chanpura <dchanp@amazon.com> * Fixes compilation issues Signed-off-by: Darshit Chanpura <dchanp@amazon.com> * Adds missing streamoutput write for configIndex fiedl Signed-off-by: Darshit Chanpura <dchanp@amazon.com> * Update SuggestConfigParamRequestTests to bring coverage to 0.60 Signed-off-by: Darshit Chanpura <dchanp@amazon.com> * Undo config indexing request to not be a docRequest Signed-off-by: Darshit Chanpura <dchanp@amazon.com> * Disabling run with feature flag as it requires decent number of changes in the rest tests Signed-off-by: Darshit Chanpura <dchanp@amazon.com> * Bump jacoco to 0.8.13 Signed-off-by: Darshit Chanpura <dchanp@amazon.com> --------- Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
1 parent c32f98d commit e0e83ac

File tree

55 files changed

+367
-493
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+367
-493
lines changed

.github/workflows/test_security.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
strategy:
2525
matrix:
2626
# empty string = disabled, flag = enabled
27-
resource_sharing_flag: ["", "-Dresource_sharing.enabled=true"]
27+
resource_sharing_flag: [""]
2828

2929
steps:
3030
- name: Run start commands

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
77
### Features
88
### Enhancements
99
- Support >1 hr intervals ([#1513](https://github.com/opensearch-project/anomaly-detection/pull/1513))
10+
- Onboards to centralized resource access control for detectors and forecasters ([#1533](https://github.com/opensearch-project/anomaly-detection/pull/1533))
1011

1112

1213
### Bug Fixes

build-tools/coverage.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
apply plugin: 'jacoco'
77

88
jacoco {
9-
toolVersion = "0.8.12"
9+
toolVersion = "0.8.13"
1010
}
1111

1212
/**

build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ dependencies {
163163
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.18.0'
164164

165165

166-
implementation "org.jacoco:org.jacoco.agent:0.8.12"
167-
implementation ("org.jacoco:org.jacoco.ant:0.8.12") {
166+
implementation "org.jacoco:org.jacoco.agent:0.8.13"
167+
implementation ("org.jacoco:org.jacoco.ant:0.8.13") {
168168
exclude group: 'org.ow2.asm', module: 'asm-commons'
169169
exclude group: 'org.ow2.asm', module: 'asm'
170170
exclude group: 'org.ow2.asm', module: 'asm-tree'
@@ -213,7 +213,7 @@ allprojects {
213213
version = "${opensearch_build}"
214214

215215
plugins.withId('jacoco') {
216-
jacoco.toolVersion = '0.8.12'
216+
jacoco.toolVersion = '0.8.13'
217217
}
218218
}
219219

@@ -375,6 +375,7 @@ integTest {
375375
systemProperty "https", System.getProperty("https")
376376
systemProperty "user", System.getProperty("user")
377377
systemProperty "password", System.getProperty("password")
378+
systemProperty "resource_sharing.enabled", System.getProperty("resource_sharing.enabled")
378379

379380
// Only rest case can run with remote cluster
380381
if (System.getProperty("tests.rest.cluster") != null) {

src/main/java/org/opensearch/ad/rest/RestAnomalyDetectorJobAction.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Locale;
2222

2323
import org.opensearch.ad.constant.ADCommonMessages;
24+
import org.opensearch.ad.indices.ADIndex;
2425
import org.opensearch.ad.settings.ADEnabledSetting;
2526
import org.opensearch.ad.transport.AnomalyDetectorJobAction;
2627
import org.opensearch.cluster.service.ClusterService;
@@ -65,7 +66,13 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli
6566
String rawPath = request.rawPath();
6667
DateRange detectionDateRange = parseInputDateRange(request);
6768

68-
JobRequest anomalyDetectorJobRequest = new JobRequest(detectorId, detectionDateRange, historical, rawPath);
69+
JobRequest anomalyDetectorJobRequest = new JobRequest(
70+
detectorId,
71+
ADIndex.CONFIG.getIndexName(),
72+
detectionDateRange,
73+
historical,
74+
rawPath
75+
);
6976

7077
return channel -> client
7178
.execute(AnomalyDetectorJobAction.INSTANCE, anomalyDetectorJobRequest, new RestToXContentListener<>(channel));

src/main/java/org/opensearch/ad/rest/RestDeleteAnomalyDetectorAction.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.Locale;
1919

2020
import org.opensearch.ad.constant.ADCommonMessages;
21+
import org.opensearch.ad.indices.ADIndex;
2122
import org.opensearch.ad.settings.ADEnabledSetting;
2223
import org.opensearch.ad.transport.DeleteAnomalyDetectorAction;
2324
import org.opensearch.rest.BaseRestHandler;
@@ -50,7 +51,7 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli
5051
}
5152

5253
String detectorId = request.param(DETECTOR_ID);
53-
DeleteConfigRequest deleteAnomalyDetectorRequest = new DeleteConfigRequest(detectorId);
54+
DeleteConfigRequest deleteAnomalyDetectorRequest = new DeleteConfigRequest(detectorId, ADIndex.CONFIG.getIndexName());
5455
return channel -> client
5556
.execute(DeleteAnomalyDetectorAction.INSTANCE, deleteAnomalyDetectorRequest, new RestToXContentListener<>(channel));
5657
}

src/main/java/org/opensearch/ad/rest/RestGetAnomalyDetectorAction.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.logging.log4j.LogManager;
2323
import org.apache.logging.log4j.Logger;
2424
import org.opensearch.ad.constant.ADCommonMessages;
25+
import org.opensearch.ad.indices.ADIndex;
2526
import org.opensearch.ad.settings.ADEnabledSetting;
2627
import org.opensearch.ad.transport.GetAnomalyDetectorAction;
2728
import org.opensearch.rest.BaseRestHandler;
@@ -64,6 +65,7 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli
6465
boolean all = request.paramAsBoolean("_all", false);
6566
GetConfigRequest getConfigRequest = new GetConfigRequest(
6667
detectorId,
68+
ADIndex.CONFIG.getIndexName(),
6769
RestActions.parseVersion(request),
6870
returnJob,
6971
returnTask,

src/main/java/org/opensearch/ad/rest/handler/IndexAnomalyDetectorActionHandler.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,27 @@ public class IndexAnomalyDetectorActionHandler extends AbstractAnomalyDetectorAc
3737
/**
3838
* Constructor function.
3939
*
40-
* @param clusterService ClusterService
41-
* @param client ES node client that executes actions on the local node
42-
* @param clientUtil AD client util
43-
* @param transportService ES transport service
44-
* @param anomalyDetectionIndices anomaly detector index manager
45-
* @param detectorId detector identifier
46-
* @param seqNo sequence number of last modification
47-
* @param primaryTerm primary term of last modification
48-
* @param refreshPolicy refresh policy
49-
* @param anomalyDetector anomaly detector instance
50-
* @param requestTimeout request time out configuration
40+
* @param clusterService ClusterService
41+
* @param client ES node client that executes actions on the local node
42+
* @param clientUtil AD client util
43+
* @param transportService ES transport service
44+
* @param anomalyDetectionIndices anomaly detector index manager
45+
* @param detectorId detector identifier
46+
* @param seqNo sequence number of last modification
47+
* @param primaryTerm primary term of last modification
48+
* @param refreshPolicy refresh policy
49+
* @param anomalyDetector anomaly detector instance
50+
* @param requestTimeout request time out configuration
5151
* @param maxSingleStreamDetectors max single-stream anomaly detectors allowed
52-
* @param maxHCDetectors max HC detectors allowed
53-
* @param maxFeatures max features allowed per detector
54-
* @param maxCategoricalFields max number of categorical fields
55-
* @param method Rest Method type
56-
* @param xContentRegistry Registry which is used for XContentParser
57-
* @param user User context
58-
* @param adTaskManager AD Task manager
59-
* @param searchFeatureDao Search feature dao
60-
* @param settings Node settings
52+
* @param maxHCDetectors max HC detectors allowed
53+
* @param maxFeatures max features allowed per detector
54+
* @param maxCategoricalFields max number of categorical fields
55+
* @param method Rest Method type
56+
* @param xContentRegistry Registry which is used for XContentParser
57+
* @param user User context
58+
* @param adTaskManager AD Task manager
59+
* @param searchFeatureDao Search feature dao
60+
* @param settings Node settings
6161
*/
6262
public IndexAnomalyDetectorActionHandler(
6363
ClusterService clusterService,

src/main/java/org/opensearch/ad/transport/AnomalyDetectorJobTransportAction.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public AnomalyDetectorJobTransportAction(
6363
FAIL_TO_STOP_DETECTOR,
6464
AnomalyDetector.class,
6565
adIndexJobActionHandler,
66-
ADIndex.CONFIG.getIndexName(),
6766
Clock.systemUTC() // inject cannot find clock due to OS limitation
6867
);
6968
}

src/main/java/org/opensearch/ad/transport/AnomalyResultRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.opensearch.action.ActionRequestValidationException;
2323
import org.opensearch.ad.constant.ADCommonMessages;
2424
import org.opensearch.ad.constant.ADCommonName;
25+
import org.opensearch.ad.indices.ADIndex;
2526
import org.opensearch.core.common.Strings;
2627
import org.opensearch.core.common.io.stream.InputStreamStreamInput;
2728
import org.opensearch.core.common.io.stream.OutputStreamStreamOutput;
@@ -37,7 +38,7 @@ public AnomalyResultRequest(StreamInput in) throws IOException {
3738
}
3839

3940
public AnomalyResultRequest(String adID, long start, long end) {
40-
super(adID, start, end);
41+
super(adID, ADIndex.CONFIG.getIndexName(), start, end);
4142
}
4243

4344
@Override

0 commit comments

Comments
 (0)