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

update vuln col on login #1002

Merged
merged 4 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 16 additions & 0 deletions apps/dashboard/src/main/java/com/akto/action/LoginAction.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.akto.action;

import com.akto.dao.BackwardCompatibilityDao;
import com.akto.dao.SignupDao;
import com.akto.dao.SingleTypeInfoDao;
import com.akto.dao.UsersDao;
import com.akto.dao.context.Context;
import com.akto.dto.BackwardCompatibility;
import com.akto.dto.Config;
import com.akto.dto.SignupInfo;
import com.akto.dto.SignupUserInfo;
import com.akto.dto.User;
import com.akto.listener.RuntimeListener;
import com.akto.utils.Token;
import com.akto.utils.JWT;
import com.mongodb.BasicDBObject;
Expand Down Expand Up @@ -99,6 +102,19 @@ public String execute() throws IOException {

private void decideFirstPage(BasicDBObject loginResult, int accountId){
Context.accountId.set(accountId);
try {
// add backward compatibility check
BackwardCompatibility backwardCompatibility = BackwardCompatibilityDao.instance.findOne(new BasicDBObject());
if (backwardCompatibility.getVulnerableApiUpdationVersionV1() == 0) {
RuntimeListener.addSampleData();
}
BackwardCompatibilityDao.instance.updateOne(
Filters.eq("_id", backwardCompatibility.getId()),
Updates.set(BackwardCompatibility.VULNERABLE_API_UPDATION_VERSION_V1, Context.now())
);
} catch (Exception e) {
logger.error("error updating vulnerable api's collection" + e.getMessage());
}
long count = SingleTypeInfoDao.instance.getEstimatedCount();
if(count == 0){
logger.info("New user, showing quick start page");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void accept(Account account) {

try {
initialiseDemoCollections();
addSampleData();
//addSampleData();
} catch (Exception e) {
loggerMaker.errorAndAddToDb(e,"Error while initialising demo collections: " + e, LoggerMaker.LogDb.DASHBOARD);
}
Expand Down
14 changes: 13 additions & 1 deletion libs/dao/src/main/java/com/akto/dto/BackwardCompatibility.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,15 @@ public class BackwardCompatibility {
public static final String DEFAULT_TELEMETRY_SETTINGS = "defaultTelemetrySettings";
private int defaultTelemetrySettings;

public static final String VULNERABLE_API_UPDATION_VERSION_V1 = "vulnerableApiUpdationVersionV1";
private int vulnerableApiUpdationVersionV1;

public BackwardCompatibility(int id, int dropFilterSampleData, int resetSingleTypeInfoCount, int dropWorkflowTestResult,
int readyForNewTestingFramework,int addAktoDataTypes, boolean deploymentStatusUpdated,
int authMechanismData, boolean mirroringLambdaTriggered, int deleteAccessListFromApiToken,
int deleteNullSubCategoryIssues, int enableNewMerging,
int aktoDefaultNewUI, int initializeOrganizationAccountBelongsTo, int orgsInBilling,
int computeIntegratedConnections, int deleteLastCronRunInfo) {
int computeIntegratedConnections, int deleteLastCronRunInfo, int vulnerableApiUpdationVersionV1) {
this.id = id;
this.dropFilterSampleData = dropFilterSampleData;
this.resetSingleTypeInfoCount = resetSingleTypeInfoCount;
Expand All @@ -83,6 +86,7 @@ public BackwardCompatibility(int id, int dropFilterSampleData, int resetSingleTy
this.initializeOrganizationAccountBelongsTo = initializeOrganizationAccountBelongsTo;
this.orgsInBilling = orgsInBilling;
this.deleteLastCronRunInfo = deleteLastCronRunInfo;
this.vulnerableApiUpdationVersionV1 = vulnerableApiUpdationVersionV1;
}

public BackwardCompatibility() {
Expand Down Expand Up @@ -247,4 +251,12 @@ public int getDefaultTelemetrySettings() {
public void setDefaultTelemetrySettings(int defaultTelemetrySettings) {
this.defaultTelemetrySettings = defaultTelemetrySettings;
}

public int getVulnerableApiUpdationVersionV1() {
return vulnerableApiUpdationVersionV1;
}

public void setVulnerableApiUpdationVersionV1(int vulnerableApiUpdationVersionV1) {
this.vulnerableApiUpdationVersionV1 = vulnerableApiUpdationVersionV1;
}
}
Loading