Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temp/akto policy #647

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions apps/api-runtime/src/main/java/com/akto/runtime/APICatalogSync.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public class APICatalogSync {
public Map<Integer, APICatalog> delta;
public AktoPolicyNew aktoPolicyNew;
public Map<SensitiveParamInfo, Boolean> sensitiveParamInfoBooleanMap;
public static boolean mergeAsyncOutside = true;

public APICatalogSync(String userIdentifier,int thresh, boolean fetchAllSTI) {
this.thresh = thresh;
Expand Down Expand Up @@ -185,7 +184,7 @@ public void computeDelta(URLAggregator origAggregator, boolean triggerTemplateGe
aktoPolicyNew.process(responseParams);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
loggerMaker.errorAndAddToDb("Error while processing aktoPolicyNew for" + responseParams.getRequestParams().getURL() +" : " + e.getMessage(), LogDb.RUNTIME);
}
}
}
Expand All @@ -199,18 +198,13 @@ public void computeDelta(URLAggregator origAggregator, boolean triggerTemplateGe
start = System.currentTimeMillis();
tryWithKnownURLTemplates(pendingRequests, deltaCatalog, dbCatalog, apiCollectionId );

if (!mergeAsyncOutside) {
start = System.currentTimeMillis();
tryMergingWithKnownStrictURLs(pendingRequests, dbCatalog, deltaCatalog);
} else {
for (URLStatic pending: pendingRequests.keySet()) {
RequestTemplate pendingTemplate = pendingRequests.get(pending);
RequestTemplate rt = deltaCatalog.getStrictURLToMethods().get(pending);
if (rt != null) {
rt.mergeFrom(pendingTemplate);
} else {
deltaCatalog.getStrictURLToMethods().put(pending, pendingTemplate);
}
for (URLStatic pending: pendingRequests.keySet()) {
RequestTemplate pendingTemplate = pendingRequests.get(pending);
RequestTemplate rt = deltaCatalog.getStrictURLToMethods().get(pending);
if (rt != null) {
rt.mergeFrom(pendingTemplate);
} else {
deltaCatalog.getStrictURLToMethods().put(pending, pendingTemplate);
}
}
}
Expand Down Expand Up @@ -1217,7 +1211,7 @@ public void buildFromDB(boolean calcDiff, boolean fetchAllSTI) {

loggerMaker.infoAndAddToDb("Started building from dB", LogDb.RUNTIME);
boolean mergingCalled = false;
if (mergeAsyncOutside && fetchAllSTI ) {
if (fetchAllSTI ) {
if (Context.now() - lastMergeAsyncOutsideTs > 600) {
this.lastMergeAsyncOutsideTs = Context.now();

Expand Down Expand Up @@ -1271,9 +1265,7 @@ public void buildFromDB(boolean calcDiff, boolean fetchAllSTI) {
this.sensitiveParamInfoBooleanMap.put(sensitiveParamInfo, false);
}

if (mergeAsyncOutside) {
this.delta = new HashMap<>();
}
this.delta = new HashMap<>();


try {
Expand Down
Loading