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

github cicd comments #653

Merged
merged 55 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
6fd26a8
github action and personal run test to check what kind of data gets p…
shivam-rawat-akto Oct 12, 2023
8b13c06
allow only test to run
shivam-rawat-akto Oct 12, 2023
f9be321
allow only test to run
shivam-rawat-akto Oct 12, 2023
21d0263
allow only test to run
shivam-rawat-akto Oct 12, 2023
cf07fa0
allow only test to run
shivam-rawat-akto Oct 12, 2023
d8e28a3
allow only test to run
shivam-rawat-akto Oct 12, 2023
6c61559
reverting staging.yml
shivam-rawat-akto Oct 12, 2023
db86132
github app settings and publishing comment on pull request
shivam-rawat-akto Oct 13, 2023
0b06ce3
github run on pr commit
shivam-rawat-akto Oct 13, 2023
959c8b9
github run on pr commit
shivam-rawat-akto Oct 13, 2023
66fcba1
staging changes for quick run
shivam-rawat-akto Oct 13, 2023
9ffa2b1
staging changes for quick run
shivam-rawat-akto Oct 13, 2023
77eb558
staging changes for quick run
shivam-rawat-akto Oct 13, 2023
43035d6
github app integration workflow
shivam-rawat-akto Oct 13, 2023
90602d8
reverting changes to staging.yml
shivam-rawat-akto Oct 13, 2023
5bba3f7
removing prod check for testing
shivam-rawat-akto Oct 13, 2023
ca5b063
hardcoding image tag for testing
shivam-rawat-akto Oct 13, 2023
eda6e7c
hardcoding image tag for testing
shivam-rawat-akto Oct 13, 2023
9a6c1a9
adding publishCommentApi in cicd
shivam-rawat-akto Oct 14, 2023
088287d
Merge remote-tracking branch 'origin/develop' into feature/github_com…
shivam-rawat-akto Oct 25, 2023
a0aa9eb
including github checks functionality
shivam-rawat-akto Oct 26, 2023
b34911f
changing test
shivam-rawat-akto Oct 26, 2023
edf42a5
allow github api's in cicd list
shivam-rawat-akto Oct 27, 2023
b0448e9
adding comment
shivam-rawat-akto Oct 27, 2023
c2a5bc2
Merge remote-tracking branch 'origin/master' into feature/github_comm…
shivam-rawat-akto Nov 1, 2023
a2e6b84
Merge remote-tracking branch 'origin/master' into feature/github_comm…
shivam-rawat-akto Nov 1, 2023
9e458b5
staging.yml changes
shivam-rawat-akto Nov 1, 2023
519dd95
staging.yml changes
shivam-rawat-akto Nov 1, 2023
2fe596a
changing version for run-test
shivam-rawat-akto Nov 1, 2023
5171a9c
removing akto build
shivam-rawat-akto Nov 1, 2023
ea52cb5
change version
shivam-rawat-akto Nov 1, 2023
03966f6
getter for testingRunResultSummaryHexId in StartTestAction
shivam-rawat-akto Nov 1, 2023
7fb4d6a
changing runscan version
shivam-rawat-akto Nov 1, 2023
f0e8184
changing runscan version
shivam-rawat-akto Nov 1, 2023
385007b
changing runscan version
shivam-rawat-akto Nov 2, 2023
2ac643b
changing runscan version
shivam-rawat-akto Nov 2, 2023
e0127b9
changing runscan version
shivam-rawat-akto Nov 2, 2023
9981eef
fix github comment
shivam-rawat-akto Nov 2, 2023
ce2f895
remove staging build process
shivam-rawat-akto Nov 2, 2023
8bd2c05
remove staging build process
shivam-rawat-akto Nov 3, 2023
3a19dca
remove staging build process
shivam-rawat-akto Nov 3, 2023
235eb0e
changing test id
shivam-rawat-akto Nov 3, 2023
f74fdd5
Merge remote-tracking branch 'origin/develop' into feature/github_com…
shivam-rawat-akto Nov 3, 2023
95f3d1f
Merge remote-tracking branch 'origin/master' into feature/github_comm…
shivam-rawat-akto Dec 11, 2023
a0f7ece
removed and added publishing comment support via testing module
shivam-rawat-akto Dec 13, 2023
470c42e
changing test tag and test id
shivam-rawat-akto Dec 14, 2023
0452e46
logs for test run
shivam-rawat-akto Dec 14, 2023
e2fe145
logs for run scan
shivam-rawat-akto Dec 14, 2023
0823eee
logs for run scan
shivam-rawat-akto Dec 15, 2023
f5aa95d
update github message
shivam-rawat-akto Dec 16, 2023
ae3b6ca
remove links
shivam-rawat-akto Dec 16, 2023
b1427b1
Merge remote-tracking branch 'origin/master' into feature/github_comm…
shivam-rawat-akto Dec 16, 2023
1925bef
Merge remote-tracking branch 'origin/master' into feature/github_comm…
shivam-rawat-akto Dec 26, 2023
3d7d137
reverting akto-test-id and run-scan version
shivam-rawat-akto Dec 26, 2023
daa8e55
text change for github and akto
shivam-rawat-akto Dec 26, 2023
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
2 changes: 1 addition & 1 deletion .github/scripts/akto-cicd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ echo "### Akto test summary" >> $GITHUB_STEP_SUMMARY
while true; do
current_time=$(date +%s)
elapsed_time=$((current_time - start_time))

if ((elapsed_time >= MAX_POLL_INTERVAL)); then
echo "Max poll interval reached. Exiting."
break
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ jobs:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

deploy:
needs: build
runs-on: ubuntu-latest
environment: Dev
permissions:
id-token: write
contents: read
env:
env:
IMAGE_TAG: ${{needs.build.outputs.IMAGE_TAG}}
FLASH_NLB_DNS: ${{ secrets.FLASH_NLB_DNS }}
FLASH_MONGO_CONN: ${{ secrets.FLASH_MONGO_CONN }}
Expand All @@ -125,7 +125,7 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_AKI_DEV_CLUSTER_02 }}
aws-secret-access-key: ${{ secrets.AWS_SAK_DEV_CLUSTER_02 }}
aws-region: ap-south-1

- name: deploy to cluster
id: deploy_cluster
uses: koslib/helm-eks-action@master
Expand Down Expand Up @@ -186,11 +186,12 @@ jobs:
with:
node-version: '17'

- uses: akto-api-security/run-scan@v1.0.10
- uses: akto-api-security/run-scan@v1.0.12
with:
AKTO_DASHBOARD_URL: https://flash.staging.akto.io
AKTO_API_KEY: ${{secrets.AKTO_API_KEY}}
AKTO_TEST_ID: 65590b1ce9fca33d79d45440
GITHUB_COMMIT_ID: ${{github.event.pull_request.head.sha}}
START_TIME_DELAY: 2
OVERRIDDEN_TEST_APP_URL: ${{needs.deploy.outputs.lb_name}}
WAIT_TIME_FOR_RESULT: 1200
Expand All @@ -213,12 +214,12 @@ jobs:
permissions:
id-token: write
contents: read
env:
env:
IMAGE_TAG: ${{needs.build.outputs.IMAGE_TAG}}
FLASH_NLB_DNS: ${{ secrets.FLASH_NLB_DNS }}
FLASH_MONGO_CONN: ${{ secrets.FLASH_MONGO_CONN }}
steps:

- name: Fetch kube yaml
#revert branch name
run: |
Expand All @@ -231,7 +232,7 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_AKI_DEV_CLUSTER_02 }}
aws-secret-access-key: ${{ secrets.AWS_SAK_DEV_CLUSTER_02 }}
aws-region: ap-south-1

- name: delete cluster
uses: koslib/helm-eks-action@master
env:
Expand Down
6 changes: 6 additions & 0 deletions apps/dashboard/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.kohsuke/github-api -->
<dependency>
<groupId>org.kohsuke</groupId>
<artifactId>github-api</artifactId>
<version>1.316</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-servlets -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
package com.akto.action.user;

import com.akto.action.UserAction;
import com.akto.action.testing.StartTestAction;
import com.akto.dao.AccountSettingsDao;
import com.akto.dao.ConfigsDao;
import com.akto.dao.RBACDao;
import com.akto.dao.UsersDao;
import com.akto.dao.context.Context;
import com.akto.dto.AccountSettings;
import com.akto.dto.Config;
import com.akto.dto.User;
import com.akto.github.GithubUtils;
import com.akto.log.LoggerMaker;
import com.akto.util.DashboardMode;
import com.mongodb.BasicDBObject;
import com.mongodb.client.model.Filters;
import com.mongodb.client.model.Updates;
import com.mongodb.client.result.DeleteResult;
import org.kohsuke.github.GitHub;
import org.kohsuke.github.GitHubBuilder;

import java.util.ArrayList;

import static com.akto.dao.AccountSettingsDao.generateFilter;

public class GithubSsoAction extends UserAction {
private static final LoggerMaker loggerMaker = new LoggerMaker(StartTestAction.class);

public String deleteGithubSso() {

Expand Down Expand Up @@ -45,8 +55,65 @@ public String deleteGithubSso() {
return SUCCESS.toUpperCase();
}

public String fetchGithubAppId() {
AccountSettings accountSettings = AccountSettingsDao.instance.findOne(generateFilter());
githubAppId = accountSettings.getGithubAppId();
return SUCCESS.toUpperCase();
}

public String deleteGithubAppSecretKey() {
if(!DashboardMode.isOnPremDeployment()){
addActionError("This feature is only available in on-prem deployment");
return ERROR.toUpperCase();
}

User user = getSUser();
boolean isAdmin = RBACDao.instance.isAdmin(user.getId(), Context.accountId.get());
if (!isAdmin) {
addActionError("Only admin can delete github app credentials");
return ERROR.toUpperCase();
}

AccountSettingsDao.instance.updateOne(generateFilter(), Updates.combine(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check isAdmin()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Updates.unset(AccountSettings.GITHUB_APP_ID),
Updates.unset(AccountSettings.GITHUB_APP_SECRET_KEY)));
addActionMessage("Deleted github app ID and secret key");
return SUCCESS.toUpperCase();
}

public String addGithubAppSecretKey() {
if(!DashboardMode.isOnPremDeployment()){
addActionError("This feature is only available in on-prem deployment");
return ERROR.toUpperCase();
}

User user = getSUser();
boolean isAdmin = RBACDao.instance.isAdmin(user.getId(), Context.accountId.get());
if (!isAdmin) {
addActionError("Only admin can delete github app credentials");
return ERROR.toUpperCase();
}
githubAppSecretKey = githubAppSecretKey.replace("-----BEGIN RSA PRIVATE KEY-----","");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check isAdmin()

githubAppSecretKey = githubAppSecretKey.replace("-----END RSA PRIVATE KEY-----","");
githubAppSecretKey = githubAppSecretKey.replace("\n","");

try {
String jwtToken = GithubUtils.createJWT(githubAppId,githubAppSecretKey, 10 * 60 * 1000);
GitHub gitHub = new GitHubBuilder().withJwtToken(jwtToken).build();
gitHub.getApp();
} catch (Exception e) {
addActionError("invalid github app Id and secret key");
return ERROR.toUpperCase();
}
AccountSettingsDao.instance.updateOne(generateFilter(), Updates.combine(Updates.set(AccountSettings.GITHUB_APP_SECRET_KEY, githubAppSecretKey),
Updates.set(AccountSettings.GITHUB_APP_ID, githubAppId)));
return SUCCESS.toUpperCase();
}
private String githubClientId;
private String githubClientSecret;
private String githubAppSecretKey;
private String githubAppId;
private String testingRunSummaryHexId;
public String addGithubSso() {

if(!DashboardMode.isOnPremDeployment()){
Expand Down Expand Up @@ -104,4 +171,28 @@ public String getGithubClientId() {
public void setGithubClientSecret(String githubClientSecret) {
this.githubClientSecret = githubClientSecret;
}

public String getGithubAppSecretKey() {
return githubAppSecretKey;
}

public void setGithubAppSecretKey(String githubAppSecretKey) {
this.githubAppSecretKey = githubAppSecretKey;
}

public String getTestingRunSummaryHexId() {
return testingRunSummaryHexId;
}

public void setTestingRunSummaryHexId(String testingRunSummaryHexId) {
this.testingRunSummaryHexId = testingRunSummaryHexId;
}

public String getGithubAppId() {
return githubAppId;
}

public void setGithubAppId(String githubAppId) {
this.githubAppId = githubAppId;
}
}
33 changes: 33 additions & 0 deletions apps/dashboard/src/main/resources/struts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,39 @@
</result>
</action>

<action name="api/fetchGithubAppId" class="com.akto.action.user.GithubSsoAction" method="fetchGithubAppId">
<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="api/addGithubAppSecretKey" class="com.akto.action.user.GithubSsoAction" method="addGithubAppSecretKey">
<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="api/deleteGithubAppSecretKey" class="com.akto.action.user.GithubSsoAction" method="deleteGithubAppSecretKey">
<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="api/getAPICatalog" class="com.akto.action.APICatalogAction" method="getAPICatalog">
<interceptor-ref name="json"/>
<interceptor-ref name="defaultStack" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useNavigate, useLocation } from "react-router-dom";

const PageWithMultipleCards = (props) => {

const {backUrl, isFirstPage, title, primaryAction, secondaryActions, divider, components} = props
const {backUrl, isFirstPage, title, primaryAction, secondaryActions, divider, components, fullWidth} = props

const location = useLocation();
const navigate = useNavigate()
Expand All @@ -21,7 +21,7 @@ const PageWithMultipleCards = (props) => {
}

return (
<Page fullWidth
<Page fullWidth={fullWidth === undefined ? true: fullWidth}
title={title}
backAction={getBackAction()}
primaryAction={primaryAction}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { UploadMajor } from '@shopify/polaris-icons';
import { useRef } from "react"


function UploadFile({ fileFormat, fileChanged, tooltipText, label, primary}) {
function UploadFile({ fileFormat, fileChanged, tooltipText, label, primary, plain}) {

const fileUploadRef = useRef("")

Expand All @@ -27,7 +27,8 @@ function UploadFile({ fileFormat, fileChanged, tooltipText, label, primary}) {
<Button
// icon={UploadMajor}
primary={primary !== undefined ? primary : true}
plain monochrome removeUnderline
plain={plain === undefined ? true: plain}
monochrome removeUnderline
onClick={onPickFile}>
{label}
<input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,27 @@ const settingRequests = {
data: {}
})
},
fetchGithubAppId() {
return request({
url: '/api/fetchGithubAppId',
method: 'post',
data: {}
})
},
addGithubAppSecretKey(githubAppSecretKey, githubAppId) {
return request({
url: '/api/addGithubAppSecretKey',
method: 'post',
data: {githubAppSecretKey, githubAppId}
})
},
deleteGithubAppSettings() {
return request({
url: '/api/deleteGithubAppSecretKey',
method: 'post',
data: {}
})
},
toggleRedactFeature(redactPayload) {
return request({
url: '/api/toggleRedactFeature',
Expand All @@ -227,7 +248,6 @@ const settingRequests = {
}
})
},

toggleNewMergingEnabled(newMergingEnabled) {
return request({
url: '/api/toggleNewMergingEnabled',
Expand All @@ -237,7 +257,6 @@ const settingRequests = {
}
});
},

updateSetupType(setupType) {
return request({
url: '/api/updateSetupType',
Expand All @@ -247,14 +266,13 @@ const settingRequests = {
}
})
},

updateTrafficAlertThresholdSeconds(trafficAlertThresholdSeconds) {
return request({
url: '/api/updateTrafficAlertThresholdSeconds',
method: 'post',
data: {trafficAlertThresholdSeconds}
})
},
}
}

export default settingRequests
Loading
Loading