-
Notifications
You must be signed in to change notification settings - Fork 553
feat: Semgrep plugin integration #2877
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
99af416
wip: semgrep sql script
iamayushm 8b929e7
semgrep sql scrit
iamayushm 522f11d
wip: adding down script
iamayushm fbbd81d
Merge branch 'main' into semgrep_plugin_integration
iamayushm d8eb81b
correcting sql script id
iamayushm 7ebba69
Merge branch 'main' into semgrep_plugin_integration
iamayushm 9d53043
fix sql script for semgrep plugin integration
vikramdevtron 8617a5e
Merge remote-tracking branch 'origin/semgrep_plugin_integration' into…
iamayushm f6cab3b
fix semgrep sql insert
vikramdevtron a95247f
Merge remote-tracking branch 'origin/semgrep_plugin_integration' into…
iamayushm 26e901b
adding semgrep icon link
iamayushm e3692d6
modifying variable description
iamayushm 3ddd4bf
adding option to pass semgrep api token from secret
iamayushm e52a5e9
adding description for semgrep app token
iamayushm 16176e6
changing semgrep logo
iamayushm 14767cd
changing variable description
iamayushm dc81b03
modifying description
iamayushm 28c4d4c
Merge branch 'main' into semgrep_plugin_integration
iamayushm 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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,6 @@ | ||
| DELETE FROM plugin_step_variable WHERE name = 'SemgrepAppToken'; | ||
| DELETE FROM plugin_step_variable WHERE name = 'PrefixAppNameInSemgrepBranchName'; | ||
| DELETE FROM plugin_step_variable WHERE name = 'UseCommitAsSemgrepBranchName'; | ||
| DELETE FROM plugin_step_variable WHERE name = 'SemgrepAppName'; | ||
| DELETE FROM plugin_step_variable WHERE name = 'ExtraCommandArguments'; | ||
| DELETE FROM plugin_step_variable WHERE name = 'GIT_MATERIAL_REQUEST'; | ||
This file contains hidden or 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,83 @@ | ||
| INSERT INTO "plugin_metadata" ("id", "name", "description","type","icon","deleted", "created_on", "created_by", "updated_on", "updated_by") VALUES (nextval('id_seq_plugin_metadata'), 'Semgrep','Semgrep is a fast, open source, static analysis engine for finding bugs, detecting dependency vulnerabilities, and enforcing code standards.','PRESET','link_to_icon','f', 'now()', 1, 'now()', 1); | ||
|
|
||
| INSERT INTO "plugin_tag_relation" ("id", "tag_id", "plugin_id", "created_on", "created_by", "updated_on", "updated_by") VALUES (nextval('id_seq_plugin_tag_relation'), 2, 6,'now()', 1, 'now()', 1); | ||
| INSERT INTO "plugin_tag_relation" ("id", "tag_id", "plugin_id", "created_on", "created_by", "updated_on", "updated_by") VALUES (nextval('id_seq_plugin_tag_relation'), 3, 6,'now()', 1, 'now()', 1); | ||
|
|
||
| INSERT INTO "plugin_pipeline_script" ("id", "script","type","deleted","created_on", "created_by", "updated_on", "updated_by") | ||
| VALUES ( | ||
| nextval('id_seq_plugin_pipeline_script'), | ||
| '#!/bin/sh | ||
| set -eo pipefail | ||
| chmod 741 /devtroncd | ||
| chmod 741 /devtroncd/* | ||
| apk add py3-pip | ||
| pip install pip==21.3.1 | ||
| pip install semgrep | ||
| export SEMGREP_APP_TOKEN=$SemgrepAppToken | ||
|
|
||
| CiMaterialsEnv=$GIT_MATERIAL_REQUEST | ||
| repoName="" | ||
| checkoutPath="" | ||
| branchName="" | ||
| gitHash="" | ||
| materials=$(echo $CiMaterialsEnv | tr "|" "\n") | ||
| for material in $materials | ||
| do | ||
| data=$(echo $material | tr "," "\n") | ||
| i=0 | ||
| for d in $data | ||
| do | ||
| if [ $((i)) == 0 ] | ||
| then | ||
| repoName=$d | ||
| elif [ $((i)) == 1 ] | ||
| then | ||
| checkoutPath=$d | ||
| elif [ $((i)) == 2 ] | ||
| then | ||
| branchName=$d | ||
| elif [ $((i)) == 3 ] | ||
| then | ||
| gitHash=$d | ||
| fi | ||
| i=$((i+1)) | ||
| done | ||
| #docker run --rm --env SEMGREP_APP_TOKEN=$SemgrepAppToken --env SEMGREP_REPO_NAME=$repoName --env SEMGREP_BRANCH=$branchName -v "${PWD}/:/src/" returntocorp/semgrep semgrep ci | ||
| cd /devtroncd | ||
| cd $checkoutPath | ||
| export SEMGREP_REPO_NAME=$repoName | ||
| if [ $UseCommitAsSemgrepBranchName == true -a $PrefixAppNameInSemgrepBranchName == true ] | ||
| then | ||
| export SEMGREP_BRANCH="$SemgrepAppName - $gitHash" | ||
| elif [ $PrefixAppNameInSemgrepBranchName == true ] | ||
| then | ||
| export SEMGREP_BRANCH="$SemgrepAppName - $branchName" | ||
| elif [ $UseCommitAsSemgrepBranchName == true ] | ||
| then | ||
| export SEMGREP_BRANCH=$gitHash | ||
| else | ||
| export SEMGREP_BRANCH=$branchName | ||
| fi | ||
| semgrep ci $ExtraCommandArguments | ||
| done' | ||
| , | ||
| 'SHELL', | ||
| 'f', | ||
| 'now()', | ||
| 1, | ||
| 'now()', | ||
| 1 | ||
| ); | ||
|
|
||
| INSERT INTO "plugin_step" ("id", "plugin_id","name","description","index","step_type","script_id","deleted", "created_on", "created_by", "updated_on", "updated_by") VALUES (nextval('id_seq_plugin_step'), 6,'Step 1','Step 1 - Dependency Track for Semgrep','1','INLINE',6,'f','now()', 1, 'now()', 1); | ||
kartik-579 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
vikramdevtron marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| INSERT INTO "plugin_step_variable" ("id", "plugin_step_id", "name", "format", "description", "is_exposed", "allow_empty_value", "variable_type", "value_type", "variable_step_index", "deleted", "created_on", "created_by", "updated_on", "updated_by") VALUES | ||
| (nextval('id_seq_plugin_step_variable'), 6, 'SemgrepAppToken','STRING','App token of Semgrep account',true,false,'INPUT','NEW',1 ,'f','now()', 1, 'now()', 1), | ||
| (nextval('id_seq_plugin_step_variable'), 6, 'PrefixAppNameInSemgrepBranchName','BOOL','if true, this will publish scan results by name {SemgrepAppName}-{branchName}',true,false,'INPUT','NEW',1 ,'f','now()', 1, 'now()', 1), | ||
| (nextval('id_seq_plugin_step_variable'), 6, 'UseCommitAsSemgrepBranchName','BOOL','if true, this will publish scan results by name {SemgrepAppName}-{CommitHash}',true,false,'INPUT','NEW',1 ,'f','now()', 1, 'now()', 1), | ||
| (nextval('id_seq_plugin_step_variable'), 6, 'SemgrepAppName','STRING','App Name will be used as an extra metadata for publishing results',true,false,'INPUT','NEW',1 ,'f','now()', 1, 'now()', 1), | ||
| (nextval('id_seq_plugin_step_variable'), 6, 'ExtraCommandArguments','STRING','Extra Command arguments for semgrep CI command. eg input - --json --sem',true,true,'INPUT','NEW',1 ,'f','now()', 1, 'now()', 1); | ||
|
|
||
| INSERT INTO "plugin_step_variable" ("id", "plugin_step_id", "name", "format", "description", "is_exposed", "allow_empty_value","value","variable_type", "value_type", "variable_step_index",reference_variable_name, "deleted", "created_on", "created_by", "updated_on", "updated_by") VALUES | ||
| (nextval('id_seq_plugin_step_variable'), 6, 'GIT_MATERIAL_REQUEST','STRING','git material data',false,true,3,'INPUT','GLOBAL',1 ,'GIT_MATERIAL_REQUEST','f','now()', 1, 'now()', 1); | ||
|
||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.