Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
5d9d399
Adding Jenkinsfile
sstephenson-r7 Feb 25, 2022
3ed036b
Retrying npm install command
sstephenson-r7 Feb 25, 2022
872dbac
Retrying npm install command
sstephenson-r7 Feb 25, 2022
2168469
Using withNPM plugin
sstephenson-r7 Feb 25, 2022
7215af4
Removing environment
sstephenson-r7 Feb 25, 2022
3ed9395
Changing npm installation command
sstephenson-r7 Feb 25, 2022
86c4a79
Updating rapid7 main DF-4183 branch
sstephenson-r7 Mar 2, 2022
92306ad
Adding nodejs download
sstephenson-r7 Mar 2, 2022
ab12e23
Removing nvm references
sstephenson-r7 Mar 2, 2022
b72e732
Activating nvm
sstephenson-r7 Mar 2, 2022
26f836e
Installing with NodeSource
sstephenson-r7 Mar 2, 2022
378c7d3
Removing sudo references
sstephenson-r7 Mar 2, 2022
206609b
Installing using NVM
sstephenson-r7 Mar 2, 2022
1eee927
Trying curl install
sstephenson-r7 Mar 2, 2022
6582344
Removing nvm reference
sstephenson-r7 Mar 2, 2022
a57fd27
Using apt install
sstephenson-r7 Mar 2, 2022
9e62281
adding podTemplate
mkridi-r7 Mar 2, 2022
cf1f32c
revert commit
mkridi-r7 Mar 2, 2022
e32f9d4
Editing jenkins agent
sstephenson-r7 Mar 3, 2022
bfe5ad7
Merge branch 'DF-4183' of github.com:rapid7/insightappsec-scan-github…
sstephenson-r7 Mar 3, 2022
4584ee7
Correcting typo in agent name
sstephenson-r7 Mar 3, 2022
6e836c9
Editing npm stages
sstephenson-r7 Mar 3, 2022
1a45f9a
Editing remove directory command
sstephenson-r7 Mar 3, 2022
85b3dbf
Setting upstream branch
sstephenson-r7 Mar 3, 2022
fde2186
Editing set upstream command
sstephenson-r7 Mar 3, 2022
54a20d0
Changing check for version number value
sstephenson-r7 Mar 3, 2022
566c75d
Attempt to create tag
sstephenson-r7 Mar 3, 2022
51507ac
Changing tagging method
sstephenson-r7 Mar 3, 2022
0e635ff
Removing node container in tagging step
sstephenson-r7 Mar 3, 2022
009a694
Adding user params
sstephenson-r7 Mar 3, 2022
6b90f68
Adding user params
sstephenson-r7 Mar 3, 2022
beb6389
Adding withCredentials
sstephenson-r7 Mar 4, 2022
5ef02ca
Adding node container for credentials
sstephenson-r7 Mar 4, 2022
757b980
Correcting withCredentials function
sstephenson-r7 Mar 4, 2022
0df73eb
Moving code into node container
sstephenson-r7 Mar 7, 2022
689f6b7
Adding git container
sstephenson-r7 Mar 7, 2022
e78ed08
Adding git container
sstephenson-r7 Mar 7, 2022
a264c7b
Removing containers from tagging stage
sstephenson-r7 Mar 7, 2022
583f4e6
Using jenkins-git-credentials
sstephenson-r7 Mar 7, 2022
2ba74bb
Removing and re-adding remote origin
sstephenson-r7 Mar 7, 2022
e2dd23e
Adding tagging script into withCredentials block
sstephenson-r7 Mar 7, 2022
c449374
Specifying origin within push command
sstephenson-r7 Mar 7, 2022
bc8617c
Editing repo name
sstephenson-r7 Mar 7, 2022
4997373
Adding when expresison for version number
sstephenson-r7 Mar 8, 2022
18507b4
Check in index.js + create release
sstephenson-r7 Mar 8, 2022
19e1bf6
Testing access to dist/index.js
sstephenson-r7 Mar 8, 2022
346f896
Updating index.js file
Mar 8, 2022
379b6f6
Editing when conditional
sstephenson-r7 Mar 8, 2022
f153c1e
Merge branch 'DF-4183' of github.com:rapid7/insightappsec-scan-github…
sstephenson-r7 Mar 8, 2022
a51e194
Checking file access
sstephenson-r7 Mar 8, 2022
2aa6075
Updating commit command
sstephenson-r7 Mar 8, 2022
8f7e68d
Updating index.js file
Mar 8, 2022
f2537d4
Re-adding tag commands
sstephenson-r7 Mar 8, 2022
607ceca
Readding tag commands
sstephenson-r7 Mar 8, 2022
d88a20a
Combining add and commit commands
sstephenson-r7 Mar 8, 2022
e4120e0
Updating index.js file
Mar 8, 2022
1c34252
Re-adding add command
sstephenson-r7 Mar 8, 2022
2cf6970
Merge branch 'DF-4183' of github.com:rapid7/insightappsec-scan-github…
sstephenson-r7 Mar 8, 2022
bbac110
Updating index.js file
Mar 8, 2022
be0762f
Changing agent
sstephenson-r7 Mar 10, 2022
4cd7dd4
Merge branch 'DF-4183' of github.com:rapid7/insightappsec-scan-github…
sstephenson-r7 Mar 10, 2022
0c968fe
Updating agent
sstephenson-r7 Mar 10, 2022
4daeaf4
Removing references to node container
sstephenson-r7 Mar 10, 2022
5392d7f
Readding node containers
sstephenson-r7 Mar 10, 2022
2757fe5
Testing stash/unstash
sstephenson-r7 Mar 10, 2022
42aa4c8
Testing dir wrapper on stash command
sstephenson-r7 Mar 10, 2022
dc9f5fb
stash test
sstephenson-r7 Mar 10, 2022
e638c76
adding unstash command
sstephenson-r7 Mar 10, 2022
62b2d02
Editing git commands after unstash
sstephenson-r7 Mar 10, 2022
501fbaf
Moving unstash command
sstephenson-r7 Mar 10, 2022
52624d2
Updating unstash command
sstephenson-r7 Mar 10, 2022
625d16d
Retrying unstash
sstephenson-r7 Mar 10, 2022
3b2e09c
Testing access to dist/index.js
sstephenson-r7 Mar 10, 2022
dc9678a
Adding delete index.js command
sstephenson-r7 Mar 10, 2022
54458e0
Correcting typo
sstephenson-r7 Mar 10, 2022
a51dd69
Removing reference to env.workspace
sstephenson-r7 Mar 10, 2022
a854744
Removing unstash command
sstephenson-r7 Mar 10, 2022
96dc8e6
Editing unstash command
sstephenson-r7 Mar 10, 2022
aaac6b3
Adding dir(WORKSPACE)
sstephenson-r7 Mar 10, 2022
32aaf76
Edit WORKSPACE reference
sstephenson-r7 Mar 10, 2022
0ca340e
Attempting to fix write access
sstephenson-r7 Mar 10, 2022
57227b4
Removing stash references
sstephenson-r7 Mar 10, 2022
1eb06d0
Testing file access logic
sstephenson-r7 Mar 10, 2022
86f92cb
Updating index.js file
Mar 10, 2022
75881b7
Adding param to prevent auto triggering pipeline
sstephenson-r7 Mar 10, 2022
4e50e25
Merge branch 'DF-4183' of github.com:rapid7/insightappsec-scan-github…
sstephenson-r7 Mar 10, 2022
a80d587
Changing param to boolean
sstephenson-r7 Mar 10, 2022
72af806
Correcting commit command
sstephenson-r7 Mar 10, 2022
1877fbb
Testing
sstephenson-r7 Mar 10, 2022
925f0ec
Updating index.js file
Mar 10, 2022
8c4fd27
Re-adding release code
sstephenson-r7 Mar 10, 2022
ea7e1a9
Merge branch 'DF-4183' of github.com:rapid7/insightappsec-scan-github…
sstephenson-r7 Mar 10, 2022
0e9f69e
Testing full run
sstephenson-r7 Mar 10, 2022
5e16588
Updating index.js file
Mar 10, 2022
013de45
Adding gh auth command
sstephenson-r7 Mar 10, 2022
4c65a55
Adding if statement for tag/release creation
sstephenson-r7 Mar 10, 2022
aadddfc
Editing if statement
sstephenson-r7 Mar 10, 2022
c0875c5
Editing if statement
sstephenson-r7 Mar 10, 2022
755f9f8
Correcting typo
sstephenson-r7 Mar 10, 2022
793071b
Editing --name-only command
sstephenson-r7 Mar 10, 2022
ca92408
Removing grep command
sstephenson-r7 Mar 10, 2022
9ca50f4
Updating index.js file
Mar 10, 2022
a86a82d
Testing git token authentication
sstephenson-r7 Mar 11, 2022
50d822a
Merge branch 'DF-4183' of github.com:rapid7/insightappsec-scan-github…
sstephenson-r7 Mar 11, 2022
d0bf45c
Adding github token reference
sstephenson-r7 Mar 11, 2022
39937c9
Removing git token reference
sstephenson-r7 Mar 11, 2022
fa20403
Authentication with Github instance
sstephenson-r7 Mar 11, 2022
6e1d49c
Retrying hostname gh
sstephenson-r7 Mar 11, 2022
36b7303
Updating index.js file
Mar 11, 2022
15ccba1
Removing release commands
sstephenson-r7 Mar 14, 2022
5fd3da2
Merge branch 'DF-4183' of github.com:rapid7/insightappsec-scan-github…
sstephenson-r7 Mar 14, 2022
5276848
Updating index.js file
Mar 14, 2022
da36b72
Updating README
sstephenson-r7 Mar 14, 2022
095c116
Update README file
sstephenson-r7 Mar 14, 2022
4b94c2c
Testing without node container
sstephenson-r7 Mar 15, 2022
ddf9a7f
Merge branch 'DF-4183' of github.com:rapid7/insightappsec-scan-github…
sstephenson-r7 Mar 15, 2022
0c137da
Re-adding node containers
sstephenson-r7 Mar 15, 2022
d4b3526
Testing removing agent
sstephenson-r7 Mar 15, 2022
7f4362d
Re-adding agent
sstephenson-r7 Mar 15, 2022
ce627d4
testing
sstephenson-r7 Mar 16, 2022
6262ff7
Re-testing for demo
sstephenson-r7 Mar 16, 2022
bce98d1
Correcting rebase
sstephenson-r7 Mar 16, 2022
761c867
Adding pull command
sstephenson-r7 Mar 16, 2022
0521866
Re-trying pull command
sstephenson-r7 Mar 16, 2022
d2a4386
Testing
sstephenson-r7 Mar 16, 2022
b3f43cc
Testing
sstephenson-r7 Mar 16, 2022
42832e0
Merge branch 'DF-4183' into DF-4183-backup
sstephenson-r7 Mar 16, 2022
ec8b3c6
Updating index.js file
Mar 16, 2022
5dda71d
Updating when expression
sstephenson-r7 Mar 16, 2022
15d4b8f
Merge branch 'DF-4183-backup' of github.com:rapid7/insightappsec-scan…
sstephenson-r7 Mar 16, 2022
d56053b
Updating index.js file
Mar 16, 2022
25eb341
Test
sstephenson-r7 Mar 16, 2022
1da28ad
Updating index.js file
Mar 16, 2022
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
97 changes: 97 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
pipeline {

agent {
kubernetes (
k8sAgent(
name: 'nodeJs',
nodeJS: "14.17.0-slim",
idleMinutes: params.POD_IDLE_MINUTES
)
)
}

parameters {
string(name: 'POD_IDLE_MINUTES', defaultValue: '0', description: 'Number of minutes pod will stay idle post build')
string(name: 'VERSION_NUMBER', description: 'InsightAppSec Github Scan tag version number')
booleanParam(name: 'RUN_PIPELINE', defaultValue: false, description: 'Option to build files and create tag')
}

stages {

//run unit tests
stage('Unit tests') {
steps {
container("node"){
script {
sh """
npm install --save-dev jest
npm t
"""
}
}
}
}

//create updated dist/index.js file
stage('Prepare build') {
when {
expression {
params.RUN_PIPELINE
!params.VERSION_NUMBER.isEmpty()
}
}
steps {
container("node"){
script {

sh """
if [ -d "node_modules" ]
then
rm -r node_modules
fi
if [ -f "dist/index.js" ]
then
rm dist/index.js
fi
npm install --production
npm i -g @vercel/ncc@0.31.1
npm run build
"""
}
}
}
}

stage('Create tag') {
when {
expression {
params.RUN_PIPELINE
!params.VERSION_NUMBER.isEmpty()
}
}
steps {

withCredentials([usernamePassword(credentialsId: 'github-app-key', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh label: 'git config user.email',
script: 'git config --global user.email github_serviceaccounts+$USERNAME@rapid7.com'
sh label: 'git config user.name',
script: 'git config --global user.name $USERNAME'

//check-in index file, create tag and release
sh """
if [ -f "dist/index.js" ]; then
git pull --ff-only https://${USERNAME}:${PASSWORD}@github.com/rapid7/insightappsec-scan-github-actions
git add dist/index.js
git commit -m "Updating index.js file"
git push https://${USERNAME}:${PASSWORD}@github.com/rapid7/insightappsec-scan-github-actions

git tag ${params.VERSION_NUMBER}
git push https://${USERNAME}:${PASSWORD}@github.com/rapid7/insightappsec-scan-github-actions ${params.VERSION_NUMBER}

fi
"""
}
}
}
}
}
40 changes: 19 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,24 @@ The body of a vulnerability query cannot contain double quotes ("), single quote
```

## Development
To develop new versions of this action
1. Make the required code updates and test
2. Remove node_modules and reinstall with the --production flag
```
npm install --production
```
3. Globally install the build tool (only once)
```
npm i -g @vercel/ncc@0.31.1
```
4. From the root project directory, in a terminal execute
```
npm run build
```
5. Add the contents of the /dist directory to the changelist.
6. Submit the changes for review.
7. Once approved and merged a tag should also be created. It's this tag that's referenced in the implementing yaml file, the below example uses a v1.0.0 tag.
```
uses: rapid7/insightappsec-scan-github-actions@v1.0.0
```
To develop new versions of this action, we use a combination of manual testing and the Jenkins CI pipeline.

1. Make the required code updates and test locally.
2. Create a fork on the repo.
3. Delete previous tags. Local: git tag -d <tagname> Remote: git push --delete origin <tagname>
4. Delete dist/index.js.
5. Remove node_modules folder.
6. Build new file: npm run build.
7. Create new tags. Local: git tag <tagname> Remote: git push origin <tagname>
8. Push branch changes to Github.
9. Checkout forked master branch and pull changes.
10. Create yaml file in workflows/.github folder, as per https://wiki.corp.rapid7.com/display/EXT/GitHub+Scan+Action "Testing Changes" section.
11. Add your AppSec API key to the forked repo as a secret named IAS_API_KEY.
12. Push any changes to the forked master branch.
13. If a scan is not kicked off automatically, make a further change to the forked repo, i.e. add an additional space to the READ_ME file.
14. If the scan runs successfully, create a PR to the rapid7 master branch. Merging will kick-off the CI pipeline.
15. In the insightappsec-scan-github-actions folder on Jenkins VRM, create a new build with parameters for your branch. Provide a tag number, i.e. v1.0.0, and tick the RUN_PIPELINE checkbox.
16. If required, manually create a new release based on your new tag.

### Unit tests
The unit tests use the jest framework. This can be installed using node package manager.
Expand All @@ -98,4 +96,4 @@ To execute all tests
- From the insightappsec-scan-github-actions directory run _npm t_

For a code coverage report
- From the insightappsec-scan-github-actions directory run _npm run coverage_
- From the insightappsec-scan-github-actions directory run _npm run coverage_
Loading