Skip to content

Commit

Permalink
Merge pull request #553 from akto-api-security/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
avneesh-akto authored Sep 18, 2023
2 parents 073bdaa + 27b7b5d commit 76f00ac
Show file tree
Hide file tree
Showing 112 changed files with 25,650 additions and 704 deletions.
6 changes: 6 additions & 0 deletions .github/scripts/deploy-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /bin/bash

cd ~/akto/infra
docker-compose -f docker-compose-dashboard.yml pull
docker-compose -f docker-compose-dashboard.yml down
docker-compose -f docker-compose-dashboard.yml up -d
36 changes: 29 additions & 7 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ jobs:
cd ../testing
docker buildx build --platform linux/arm64/v8,linux/amd64 -t $ECR_REGISTRY/akto-api-testing:$IMAGE_TAG $IMAGE_TAG_TESTING . --push
echo "::set-output name=image::$ECR_REGISTRY/akto-api-testing:$IMAGE_TAG"
- name: Update flash staging
if: ${{ github.event.inputs.Environment == 'prod' && github.event.inputs.Deploy == 'true' }}
run: |
curl https://flash.staging.akto.io/api/takeUpdate -H X-API-KEY:${{secrets.AKTO_API_KEY}}
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
Expand All @@ -121,11 +117,37 @@ jobs:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

deploy:
if: ${{ github.event.inputs.Environment == 'prod' && github.event.inputs.Deploy == 'true' }}
needs: build
runs-on: ubuntu-latest
environment: Dev
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v2
- uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.IAMROLE_GITHUB }}
role-session-name: GitHub-Action-Role
aws-region: ${{ vars.AWS_REGION }}
- name: Deploy to flash
run: |
echo "Deploying branch ${{ env.GITHUB_REF }} to ${{ github.event.inputs.environment }}"
commit_hash=`git rev-parse HEAD`
aws deploy create-deployment --application-name flash-deploy --deployment-group-name flash-deployment-group --github-location repository=$GITHUB_REPOSITORY,commitId=$commit_hash --ignore-application-stop-failures
test:
if: ${{ github.event.inputs.Environment == 'prod' && github.event.inputs.Deploy == 'true' }}
needs: deploy
runs-on: ubuntu-latest
steps:
- name: Run CI/CD tests
if: ${{ github.event.inputs.Environment == 'prod' && github.event.inputs.Deploy == 'true' }}
uses: oren-akto/akto-github-action@v1.0.0
uses: akto-api-security/run-scan@v1.0.3
with:
AKTO_DASHBOARD_URL: ${{vars.AKTO_DASHBOARD_URL}}
AKTO_API_KEY: ${{vars.AKTO_API_KEY}}
AKTO_API_KEY: ${{secrets.AKTO_API_KEY}}
AKTO_TEST_ID: ${{vars.AKTO_TEST_ID}}
START_TIME_DELAY: 180
17 changes: 17 additions & 0 deletions apps/dashboard/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"file-saver": "^2.0.5",
"highcharts": "^9.0.1",
"highcharts-vue": "^1.0.4",
"leven": "^4.0.0",
"monaco-editor": "^0.38.0",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,21 @@ public BasicDBObject getDataTypes() {

private CustomDataType customDataType;;

private boolean checkConditionUpdate(CustomDataType existingCDT, CustomDataType newCDT) {
boolean ret = true;

ret &= Conditions.areEqual(existingCDT.getKeyConditions(), newCDT.getKeyConditions());
ret &= Conditions.areEqual(existingCDT.getValueConditions(), newCDT.getValueConditions());

// check for operator change only if both key and value conditions are being used.
if(ret && (newCDT.getKeyConditions()!=null && newCDT.getValueConditions()!=null)){
ret &= existingCDT.getOperator() == newCDT.getOperator();
}

// false if all of them are true and true if any of them is false
return !ret;
}

@Override
public String execute() {
User user = getSUser();
Expand All @@ -142,16 +157,23 @@ public String execute() {
addActionError("There is something wrong in the data type conditions");
return ERROR.toUpperCase();
}


CustomDataType customDataTypeFromDb = CustomDataTypeDao.instance.findOne(Filters.eq(CustomDataType.NAME, name));
if (this.createNew) {
CustomDataType customDataTypeFromDb = CustomDataTypeDao.instance.findOne(Filters.eq(CustomDataType.NAME, name));
if (customDataTypeFromDb != null) {
addActionError("Data type with same name exists");
return ERROR.toUpperCase();
}
// id is automatically set when inserting in pojo
CustomDataTypeDao.instance.insertOne(customDataType);
} else {

if (customDataTypeFromDb!=null && customDataTypeFromDb.getCreatorId() == 1638571050 &&
checkConditionUpdate(customDataTypeFromDb, customDataType)) {
addActionError("Cannot update data type conditions for akto data types. Please create a new data type.");
return ERROR.toUpperCase();
}

FindOneAndUpdateOptions options = new FindOneAndUpdateOptions();
options.returnDocument(ReturnDocument.AFTER);
options.upsert(false);
Expand Down
Loading

0 comments on commit 76f00ac

Please sign in to comment.