Skip to content

Commit

Permalink
Merge pull request #1133 from akto-api-security/hotfix/fix_dibs_funct…
Browse files Browse the repository at this point in the history
…ionality

Changed dibs call in crons
  • Loading branch information
aktoboy authored May 20, 2024
2 parents af2d053 + 719770b commit 46a1941
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ public void accept(Account t) {
ex.printStackTrace(); // or loggger would be better
}
}
}, 0, 5, TimeUnit.MINUTES);
}, 0, 4, TimeUnit.HOURS);

}

Expand Down Expand Up @@ -895,7 +895,7 @@ public void accept(Account t) {
}
}, "webhook-sener");
}
}, 0, 15, TimeUnit.MINUTES);
}, 0, 1, TimeUnit.HOURS);
}

static class ChangesInfo {
Expand Down Expand Up @@ -2479,6 +2479,12 @@ public static void syncWithAkto() {
public void setupUsageScheduler() {
scheduler.scheduleAtFixedRate(new Runnable() {
public void run() {
Context.accountId.set(1000_000);
boolean dibs = callDibs("usage-scheduler", 60*60, 60);
if (!dibs) {
loggerMaker.infoAndAddToDb("Usage cron dibs not acquired, skipping usage cron", LoggerMaker.LogDb.DASHBOARD);
return;
}
calcUsage();
}
}, 0, 1, UsageUtils.USAGE_CRON_PERIOD);
Expand Down
12 changes: 7 additions & 5 deletions apps/dashboard/src/main/java/com/akto/utils/crons/SyncCron.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ public class SyncCron {
public void setUpUpdateCronScheduler() {
scheduler.scheduleAtFixedRate(new Runnable() {
public void run() {

Context.accountId.set(1000_000);
boolean dibs = callDibs(Cluster.SYNC_CRON_INFO, 300, 60);
if(!dibs){
loggerMaker.infoAndAddToDb("Cron for updating new parameters, new endpoints and severity score dibs not acquired, thus skipping cron", LogDb.DASHBOARD);
return;
}
AccountTask.instance.executeTask(new Consumer<Account>() {
@Override
public void accept(Account t) {
boolean dibs = callDibs(Cluster.SYNC_CRON_INFO, 300, 60);
if(!dibs){
loggerMaker.infoAndAddToDb("Cron for updating new parameters, new endpoints and severity score dibs not acquired, thus skipping cron", LogDb.DASHBOARD);
return;
}
AccountSettings accountSettings = AccountSettingsDao.instance.findOne(AccountSettingsDao.generateFilter());
LastCronRunInfo lastRunTimerInfo = accountSettings.getLastUpdatedCronInfo();
loggerMaker.infoAndAddToDb("Cron for updating new parameters, new endpoints and severity score picked up " + accountSettings.getId(), LogDb.DASHBOARD);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.function.Consumer;

import com.akto.dao.AccountSettingsDao;
import com.akto.dao.context.Context;
import com.akto.dto.Account;
import com.akto.dto.AccountSettings;
import com.akto.log.LoggerMaker;
Expand All @@ -26,14 +27,16 @@ public class UpdateSensitiveInfoInApiInfo {
public void setUpSensitiveMapInApiInfoScheduler() {
scheduler.scheduleAtFixedRate(new Runnable() {
public void run() {

Context.accountId.set(1000_000);
boolean dibs = callDibs(Cluster.MAP_SENSITIVE_IN_INFO, 900, 60);
if(!dibs){
loggerMaker.infoAndAddToDb("Cron for mapping sensitive info not picked up as dibs is acquired.", LogDb.DASHBOARD);
return;
}
AccountTask.instance.executeTask(new Consumer<Account>() {
@Override
public void accept(Account t) {
boolean dibs = callDibs(Cluster.MAP_SENSITIVE_IN_INFO, 900, 60);
if(!dibs){
loggerMaker.infoAndAddToDb("Cron for mapping sensitive info to apiInfo dibs not acquired, thus skipping cron", LogDb.DASHBOARD);
return;
}
AccountSettings accountSettings = AccountSettingsDao.instance.findOne(AccountSettingsDao.generateFilter());
loggerMaker.infoAndAddToDb("Cron for mapping sensitive info picked up by " + accountSettings.getId(), LogDb.DASHBOARD);
LastCronRunInfo lastRunTimerInfo = accountSettings.getLastUpdatedCronInfo();
Expand Down

0 comments on commit 46a1941

Please sign in to comment.