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

fix: fixed demerge bug in miniruntime #1741

Open
wants to merge 1 commit into
base: feature/mini-runtime-release
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -804,9 +804,12 @@ public static String[] tokenize(String url) {
}

Map<String, SingleTypeInfo> convertToMap(List<SingleTypeInfo> l) {
Set<MergedUrls> mergedUrls = dataActor.fetchMergedUrls();
Map<String, SingleTypeInfo> ret = new HashMap<>();
for(SingleTypeInfo e: l) {
ret.put(e.composeKey(), e);
if(!mergedUrls.contains(new MergedUrls(e.getUrl(), e.getMethod(), e.getApiCollectionId()))) {
ret.put(e.composeKey(), e);
}
}

return ret;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.akto.dao.context.Context;
import com.akto.dto.*;
import com.akto.dto.ApiInfo.ApiInfoKey;
import com.akto.dto.filter.MergedUrls;
import com.akto.dto.runtime_filters.RuntimeFilter;
import com.akto.runtime.policies.*;
import com.akto.dto.type.APICatalog;
Expand Down Expand Up @@ -35,7 +36,7 @@ public class AktoPolicyNew {
ApiAccessTypePolicy apiAccessTypePolicy = new ApiAccessTypePolicy(null, null);
boolean redact = false;

private DataActor dataActor = DataActorFactory.fetchInstance();
private static DataActor dataActor = DataActorFactory.fetchInstance();

private static final LoggerMaker loggerMaker = new LoggerMaker(AktoPolicyNew.class);

Expand Down Expand Up @@ -257,7 +258,15 @@ public static List<ApiInfo> getUpdates(Map<Integer, ApiInfoCatalog> apiInfoCatal
for (ApiInfoCatalog apiInfoCatalog: apiInfoCatalogMap.values()) {

Map<URLStatic, PolicyCatalog> strictURLToMethods = apiInfoCatalog.getStrictURLToMethods();
Map<URLTemplate, PolicyCatalog> templateURLToMethods = apiInfoCatalog.getTemplateURLToMethods();
Map<URLTemplate, PolicyCatalog> templateURLToMethods = new HashMap<>();

Set<MergedUrls> mergedUrls = dataActor.fetchMergedUrls();
for(Map.Entry<URLTemplate, PolicyCatalog> templateURLToMethodEntry : apiInfoCatalog.getTemplateURLToMethods().entrySet()) {
ApiInfoKey apiInfoKey = templateURLToMethodEntry.getValue().getApiInfo().getId();
if(!mergedUrls.contains(new MergedUrls(apiInfoKey.getUrl(), apiInfoKey.getMethod().name(), apiInfoKey.getApiCollectionId()))) {
templateURLToMethods.put(templateURLToMethodEntry.getKey(), templateURLToMethodEntry.getValue());
}
}

List<PolicyCatalog> policyCatalogList = new ArrayList<>();
policyCatalogList.addAll(strictURLToMethods.values());
Expand Down
Loading