-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1902 from akto-api-security/dashboard-only-threat…
…-protection threat detection dashboard
- Loading branch information
Showing
39 changed files
with
2,231 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ https: | |
**/data-zoo-data | ||
**/data-zoo-logs | ||
**/bin | ||
.factorypath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
proto-gen: | ||
sh ./scripts/proto-gen.sh | ||
|
||
build: proto-gen | ||
mvn install -DskipTests | ||
|
||
build-clean: proto-gen | ||
mvn clean install -DskipTests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...shboard/src/main/java/com/akto/action/threat_detection/AbstractThreatDetectionAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.akto.action.threat_detection; | ||
|
||
import com.akto.action.UserAction; | ||
import com.akto.dao.context.Context; | ||
import com.akto.database_abstractor_authenticator.JwtAuthenticator; | ||
import java.util.Calendar; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class AbstractThreatDetectionAction extends UserAction { | ||
|
||
private Map<Integer, String> tokens = new HashMap<>(); | ||
private String backendUrl; | ||
|
||
public AbstractThreatDetectionAction() { | ||
super(); | ||
this.backendUrl = System.getenv().getOrDefault("THREAT_DETECTION_BACKEND_URL", "https://tbs.akto.io"); | ||
} | ||
|
||
public String getApiToken() { | ||
try { | ||
int accountId = Context.accountId.get(); | ||
if (tokens.containsKey(accountId)) { | ||
return tokens.get(accountId); | ||
} | ||
|
||
Map<String, Object> claims = new HashMap<>(); | ||
claims.put("accountId", accountId); | ||
String token = JwtAuthenticator.createJWT(claims, "Akto", "access_tbs", Calendar.MINUTE, 1); | ||
tokens.put(accountId, token); | ||
|
||
return token; | ||
} catch (Exception e) { | ||
System.out.println(e); | ||
return ""; | ||
} | ||
} | ||
|
||
public String getBackendUrl() { | ||
return backendUrl; | ||
} | ||
} |
111 changes: 111 additions & 0 deletions
111
apps/dashboard/src/main/java/com/akto/action/threat_detection/DashboardMaliciousEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package com.akto.action.threat_detection; | ||
|
||
import com.akto.dto.type.URLMethods; | ||
import com.akto.dto.type.URLMethods.Method; | ||
|
||
public class DashboardMaliciousEvent { | ||
private String id; | ||
private String actor; | ||
private String filter_id; | ||
private String url; | ||
private URLMethods.Method method; | ||
private int apiCollectionId; | ||
private String ip; | ||
private String country; | ||
private long timestamp; | ||
|
||
public DashboardMaliciousEvent() {} | ||
|
||
public DashboardMaliciousEvent( | ||
String id, | ||
String actor, | ||
String filter, | ||
String url, | ||
Method method, | ||
int apiCollectionId, | ||
String ip, | ||
String country, | ||
long timestamp) { | ||
this.id = id; | ||
this.actor = actor; | ||
this.filter_id = filter; | ||
this.url = url; | ||
this.method = method; | ||
this.apiCollectionId = apiCollectionId; | ||
this.ip = ip; | ||
this.country = country; | ||
this.timestamp = timestamp; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getActor() { | ||
return actor; | ||
} | ||
|
||
public void setActor(String actor) { | ||
this.actor = actor; | ||
} | ||
|
||
public String getFilterId() { | ||
return filter_id; | ||
} | ||
|
||
public void setFilterId(String filter) { | ||
this.filter_id = filter; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
|
||
public URLMethods.Method getMethod() { | ||
return method; | ||
} | ||
|
||
public void setMethod(URLMethods.Method method) { | ||
this.method = method; | ||
} | ||
|
||
public String getIp() { | ||
return ip; | ||
} | ||
|
||
public void setIp(String ip) { | ||
this.ip = ip; | ||
} | ||
|
||
public String getCountry() { | ||
return country; | ||
} | ||
|
||
public void setCountry(String country) { | ||
this.country = country; | ||
} | ||
|
||
public long getTimestamp() { | ||
return timestamp; | ||
} | ||
|
||
public void setTimestamp(long timestamp) { | ||
this.timestamp = timestamp; | ||
} | ||
|
||
public int getApiCollectionId() { | ||
return apiCollectionId; | ||
} | ||
|
||
public void setApiCollectionId(int apiCollectionId) { | ||
this.apiCollectionId = apiCollectionId; | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
apps/dashboard/src/main/java/com/akto/action/threat_detection/DashboardThreatActor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.akto.action.threat_detection; | ||
|
||
import com.akto.dto.type.URLMethods.Method; | ||
|
||
public class DashboardThreatActor { | ||
|
||
private String id; | ||
private String latestApiEndpoint; | ||
private String latestApiIp; | ||
private Method latestApiMethod; | ||
private long discoveredAt; | ||
private String country; | ||
|
||
public DashboardThreatActor( | ||
String id, | ||
String latestApiEndpoint, | ||
String latestApiIp, | ||
Method latestApiMethod, | ||
long discoveredAt, | ||
String country) { | ||
|
||
this.id = id; | ||
this.latestApiEndpoint = latestApiEndpoint; | ||
this.latestApiIp = latestApiIp; | ||
this.latestApiMethod = latestApiMethod; | ||
this.discoveredAt = discoveredAt; | ||
this.country = country; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getLatestApiEndpoint() { | ||
return latestApiEndpoint; | ||
} | ||
|
||
public void setLatestApiEndpoint(String latestApiEndpoint) { | ||
this.latestApiEndpoint = latestApiEndpoint; | ||
} | ||
|
||
public String getLatestApiIp() { | ||
return latestApiIp; | ||
} | ||
|
||
public void setLatestApiIp(String latestApiIp) { | ||
this.latestApiIp = latestApiIp; | ||
} | ||
|
||
public Method getLatestApiMethod() { | ||
return latestApiMethod; | ||
} | ||
|
||
public void setLatestApiMethod(Method latestApiMethod) { | ||
this.latestApiMethod = latestApiMethod; | ||
} | ||
|
||
public long getDiscoveredAt() { | ||
return discoveredAt; | ||
} | ||
|
||
public void setDiscoveredAt(long discoveredAt) { | ||
this.discoveredAt = discoveredAt; | ||
} | ||
|
||
public String getCountry() { | ||
return country; | ||
} | ||
|
||
public void setCountry(String country) { | ||
this.country = country; | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
apps/dashboard/src/main/java/com/akto/action/threat_detection/DashboardThreatApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.akto.action.threat_detection; | ||
|
||
import com.akto.dto.type.URLMethods; | ||
|
||
public class DashboardThreatApi { | ||
|
||
private String api; | ||
private URLMethods.Method method; | ||
private int actorsCount; | ||
private int requestsCount; | ||
private long discoveredAt; | ||
|
||
public DashboardThreatApi( | ||
String api, URLMethods.Method method, int actorsCount, int requestsCount, long discoveredAt) { | ||
this.api = api; | ||
this.method = method; | ||
this.actorsCount = actorsCount; | ||
this.requestsCount = requestsCount; | ||
this.discoveredAt = discoveredAt; | ||
} | ||
|
||
public String getApi() { | ||
return api; | ||
} | ||
|
||
public void setApi(String api) { | ||
this.api = api; | ||
} | ||
|
||
public URLMethods.Method getMethod() { | ||
return method; | ||
} | ||
|
||
public void setMethod(URLMethods.Method method) { | ||
this.method = method; | ||
} | ||
|
||
public int getActorsCount() { | ||
return actorsCount; | ||
} | ||
|
||
public void setActorsCount(int actorsCount) { | ||
this.actorsCount = actorsCount; | ||
} | ||
|
||
public int getRequestsCount() { | ||
return requestsCount; | ||
} | ||
|
||
public void setRequestsCount(int requestsCount) { | ||
this.requestsCount = requestsCount; | ||
} | ||
|
||
public long getDiscoveredAt() { | ||
return discoveredAt; | ||
} | ||
|
||
public void setDiscoveredAt(long discoveredAt) { | ||
this.discoveredAt = discoveredAt; | ||
} | ||
} |
Oops, something went wrong.