-
Notifications
You must be signed in to change notification settings - Fork 215
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
github cicd comments #653
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 8b13c06
allow only test to run
shivam-rawat-akto f9be321
allow only test to run
shivam-rawat-akto 21d0263
allow only test to run
shivam-rawat-akto cf07fa0
allow only test to run
shivam-rawat-akto d8e28a3
allow only test to run
shivam-rawat-akto 6c61559
reverting staging.yml
shivam-rawat-akto db86132
github app settings and publishing comment on pull request
shivam-rawat-akto 0b06ce3
github run on pr commit
shivam-rawat-akto 959c8b9
github run on pr commit
shivam-rawat-akto 66fcba1
staging changes for quick run
shivam-rawat-akto 9ffa2b1
staging changes for quick run
shivam-rawat-akto 77eb558
staging changes for quick run
shivam-rawat-akto 43035d6
github app integration workflow
shivam-rawat-akto 90602d8
reverting changes to staging.yml
shivam-rawat-akto 5bba3f7
removing prod check for testing
shivam-rawat-akto ca5b063
hardcoding image tag for testing
shivam-rawat-akto eda6e7c
hardcoding image tag for testing
shivam-rawat-akto 9a6c1a9
adding publishCommentApi in cicd
shivam-rawat-akto 088287d
Merge remote-tracking branch 'origin/develop' into feature/github_com…
shivam-rawat-akto a0aa9eb
including github checks functionality
shivam-rawat-akto b34911f
changing test
shivam-rawat-akto edf42a5
allow github api's in cicd list
shivam-rawat-akto b0448e9
adding comment
shivam-rawat-akto c2a5bc2
Merge remote-tracking branch 'origin/master' into feature/github_comm…
shivam-rawat-akto a2e6b84
Merge remote-tracking branch 'origin/master' into feature/github_comm…
shivam-rawat-akto 9e458b5
staging.yml changes
shivam-rawat-akto 519dd95
staging.yml changes
shivam-rawat-akto 2fe596a
changing version for run-test
shivam-rawat-akto 5171a9c
removing akto build
shivam-rawat-akto ea52cb5
change version
shivam-rawat-akto 03966f6
getter for testingRunResultSummaryHexId in StartTestAction
shivam-rawat-akto 7fb4d6a
changing runscan version
shivam-rawat-akto f0e8184
changing runscan version
shivam-rawat-akto 385007b
changing runscan version
shivam-rawat-akto 2ac643b
changing runscan version
shivam-rawat-akto e0127b9
changing runscan version
shivam-rawat-akto 9981eef
fix github comment
shivam-rawat-akto ce2f895
remove staging build process
shivam-rawat-akto 8bd2c05
remove staging build process
shivam-rawat-akto 3a19dca
remove staging build process
shivam-rawat-akto 235eb0e
changing test id
shivam-rawat-akto f74fdd5
Merge remote-tracking branch 'origin/develop' into feature/github_com…
shivam-rawat-akto 95f3d1f
Merge remote-tracking branch 'origin/master' into feature/github_comm…
shivam-rawat-akto a0f7ece
removed and added publishing comment support via testing module
shivam-rawat-akto 470c42e
changing test tag and test id
shivam-rawat-akto 0452e46
logs for test run
shivam-rawat-akto e2fe145
logs for run scan
shivam-rawat-akto 0823eee
logs for run scan
shivam-rawat-akto f5aa95d
update github message
shivam-rawat-akto ae3b6ca
remove links
shivam-rawat-akto b1427b1
Merge remote-tracking branch 'origin/master' into feature/github_comm…
shivam-rawat-akto 1925bef
Merge remote-tracking branch 'origin/master' into feature/github_comm…
shivam-rawat-akto 3d7d137
reverting akto-test-id and run-scan version
shivam-rawat-akto daa8e55
text change for github and akto
shivam-rawat-akto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -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() { | ||
|
||
|
@@ -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( | ||
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-----",""); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check |
||
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()){ | ||
|
@@ -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; | ||
} | ||
} |
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check
isAdmin()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done