Skip to content

Commit

Permalink
Merge branch 'develop' into feature/improve-vulnerability-report
Browse files Browse the repository at this point in the history
  • Loading branch information
oren-akto committed Jun 24, 2024
2 parents cf4c2d8 + 3a8227f commit 671d329
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 4 deletions.
23 changes: 23 additions & 0 deletions apps/dashboard/src/main/resources/struts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3499,6 +3499,29 @@
</result>
</action>

<action name="tools/convertSamleDataToBurpRequest" class="com.akto.action.ExportSampleDataAction" method="generateBurpRequest">
<interceptor-ref name="json"/>
<interceptor-ref name="defaultStack" />
<result name="SUCCESS" type="json"/>
<result name="ERROR" type="json">
<param name="statusCode">422</param>
<param name="ignoreHierarchy">false</param>
<param name="includeProperties">^actionErrors.*</param>
</result>
</action>

<action name="tools/convertSampleDataToCurl" class="com.akto.action.ExportSampleDataAction" method="generateCurl">
<interceptor-ref name="json"/>
<interceptor-ref name="defaultStack" />
<result name="SUCCESS" type="json">
</result>
<result name="ERROR" type="json">
<param name="statusCode">422</param>
<param name="ignoreHierarchy">false</param>
<param name="includeProperties">^actionErrors.*</param>
</result>
</action>

</package>

</struts>
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static GetRunningTestsStatus getRunningTests() {
public void getStatusOfRunningTests(){
scheduler.scheduleAtFixedRate(new Runnable() {
public void run(){
AccountTask.instance.executeTask(new Consumer<Account>() {
AccountTask.instance.executeTaskForNonHybridAccounts(new Consumer<Account>() {
@Override
public void accept(Account t) {
try {
Expand Down
6 changes: 3 additions & 3 deletions apps/testing/src/main/java/com/akto/testing/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private static TestingRunResultSummary createTRRSummaryIfAbsent(TestingRun testi
private static void setupRateLimitWatcher () {
scheduler.scheduleAtFixedRate(new Runnable() {
public void run() {
AccountTask.instance.executeTask(new Consumer<Account>() {
AccountTask.instance.executeTaskForNonHybridAccounts(new Consumer<Account>() {
@Override
public void accept(Account t) {
AccountSettings settings = AccountSettingsDao.instance.findOne(AccountSettingsDao.generateFilter());
Expand Down Expand Up @@ -222,7 +222,7 @@ public static void main(String[] args) throws InterruptedException {

schedulerAccessMatrix.scheduleAtFixedRate(new Runnable() {
public void run() {
AccountTask.instance.executeTask(account -> {
AccountTask.instance.executeTaskForNonHybridAccounts(account -> {
AccessMatrixAnalyzer matrixAnalyzer = new AccessMatrixAnalyzer();
try {
matrixAnalyzer.run();
Expand All @@ -239,7 +239,7 @@ public void run() {
loggerMaker.infoAndAddToDb("os.version: " + System.getProperty("os.version"), LogDb.TESTING);

while (true) {
AccountTask.instance.executeTask(account -> {
AccountTask.instance.executeTaskForNonHybridAccounts(account -> {
int accountId = account.getId();

int start = Context.now();
Expand Down
11 changes: 11 additions & 0 deletions libs/dao/src/main/java/com/akto/dto/Account.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public class Account {
private boolean mergingRunning = false;

private int mergingInitiateTs = 0;

public static final String HYBRID_TESTING_ENABLED = "hybridTestingEnabled";
private boolean hybridTestingEnabled;

public Account() {}

public Account(int id, String name) {
Expand Down Expand Up @@ -94,4 +98,11 @@ public void setHybridSaasAccount(boolean hybridSaasAccount) {
this.hybridSaasAccount = hybridSaasAccount;
}

public boolean getHybridTestingEnabled() {
return hybridTestingEnabled;
}

public void setHybridTestingEnabled(boolean hybridTestingEnabled) {
this.hybridTestingEnabled = hybridTestingEnabled;
}
}
27 changes: 27 additions & 0 deletions libs/dao/src/main/java/com/akto/util/AccountTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,31 @@ public void executeTaskHybridAccounts(Consumer<Account> consumeAccount, String t
}

}

public void executeTaskForNonHybridAccounts(Consumer<Account> consumeAccount, String taskName) {

Bson activeFilter = Filters.or(
Filters.exists(Account.INACTIVE_STR, false),
Filters.eq(Account.INACTIVE_STR, false)
);

Bson nonHybridAccountsFilter = Filters.or(
Filters.exists(Account.HYBRID_TESTING_ENABLED, false),
Filters.eq(Account.HYBRID_TESTING_ENABLED, false)
);

List<Account> activeAccounts = AccountsDao.instance.findAll(Filters.and(activeFilter, nonHybridAccountsFilter));
for(Account account: activeAccounts) {
if (inactiveAccountsSet.contains(account.getId())) {
continue;
}
try {
Context.accountId.set(account.getId());
consumeAccount.accept(account);
} catch (Exception e) {
String msgString = String.format("Error in executing task %s for account %d", taskName, account.getId());
logger.error(msgString, e);
}
}
}
}

0 comments on commit 671d329

Please sign in to comment.