Skip to content

Commit 85fccaf

Browse files
authored
Merge pull request #30 from zkoppert/configurable_delay
Get timedelta delay from config instead of hardcode 24hrs
2 parents 90d3227 + 9769e06 commit 85fccaf

File tree

11 files changed

+95
-84
lines changed

11 files changed

+95
-84
lines changed

.env-example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
GH_ACTOR=' '
22
GH_TOKEN=' '
33
ORGANIZATION=' '
4-
PR_BODY=' '
4+
PR_BODY=' '
5+
HOURS_DELAY='24'

.github/dependabot.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Please see the documentation for all configuration options:
44
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
55

6+
---
7+
68
version: 2
79
updates:
810
- package-ecosystem: "pip"

.github/linters/.hadolint.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
---
12
ignored:
2-
- DL3008
3+
- DL3008
Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
1-
# For most projects, this workflow file will not need changing; you simply need
2-
# to commit it to your repository.
3-
#
4-
# You may wish to alter this file to override the set of languages analyzed,
5-
# or to provide custom queries or build logic.
6-
#
7-
# ******** NOTE ********
8-
# We have attempted to detect the languages in your repository. Please check
9-
# the `language` matrix defined below to confirm you have the correct set of
10-
# supported CodeQL languages.
11-
#
1+
---
122
name: "CodeQL"
133

144
on:
155
push:
16-
branches: [ main ]
6+
branches: [main]
177
pull_request:
188
# The branches below must be a subset of the branches above
19-
branches: [ main ]
9+
branches: [main]
2010
schedule:
2111
- cron: '39 14 * * 0'
2212

@@ -32,40 +22,19 @@ jobs:
3222
strategy:
3323
fail-fast: false
3424
matrix:
35-
language: [ 'python' ]
36-
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
37-
# Learn more:
38-
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
25+
language: ['python']
3926

4027
steps:
41-
- name: Checkout repository
42-
uses: actions/checkout@v2
28+
- name: Checkout repository
29+
uses: actions/checkout@v2
4330

44-
# Initializes the CodeQL tools for scanning.
45-
- name: Initialize CodeQL
46-
uses: github/codeql-action/init@v1
47-
with:
48-
languages: ${{ matrix.language }}
49-
# If you wish to specify custom queries, you can do so here or in a config file.
50-
# By default, queries listed here will override any specified in a config file.
51-
# Prefix the list here with "+" to use these queries and those in the config file.
52-
# queries: ./path/to/local/query, your-org/your-repo/queries@main
31+
- name: Initialize CodeQL
32+
uses: github/codeql-action/init@v1
33+
with:
34+
languages: ${{ matrix.language }}
5335

54-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55-
# If this step fails, then you should remove it and run the build manually (see below)
56-
- name: Autobuild
57-
uses: github/codeql-action/autobuild@v1
36+
- name: Autobuild
37+
uses: github/codeql-action/autobuild@v1
5838

59-
# ℹ️ Command-line programs to run using the OS shell.
60-
# 📚 https://git.io/JvXDl
61-
62-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63-
# and modify them (or add more) to build your code if your project
64-
# uses a compiled language
65-
66-
#- run: |
67-
# make bootstrap
68-
# make release
69-
70-
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@v1
39+
- name: Perform CodeQL Analysis
40+
uses: github/codeql-action/analyze@v1

.github/workflows/docker-image.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
---
12
name: Docker Image CI
23

34
on:
45
push:
5-
branches: [ main ]
6+
branches: [main]
67
pull_request:
7-
branches: [ main ]
8+
branches: [main]
89

910
jobs:
1011

@@ -13,6 +14,6 @@ jobs:
1314
runs-on: ubuntu-latest
1415

1516
steps:
16-
- uses: actions/checkout@v2
17-
- name: Build the Docker image
18-
run: docker build . --file Dockerfile --tag enforcer:"$(date +%s)"
17+
- uses: actions/checkout@v2
18+
- name: Build the Docker image
19+
run: docker build . --file Dockerfile --tag enforcer:"$(date +%s)"

.github/workflows/linter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
push:
1313
branches: [main]
1414
pull_request:
15-
branches-ignore: []
15+
branches-ignore: [ ]
1616

1717
###############
1818
# Set the Job #

.github/workflows/release-drafter.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
name: Release Drafter
23

34
on:

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,14 @@ jobs:
3434
GH_TOKEN: ${{ secrets.GH_TOKEN }}
3535
ORGANIZATION: ${{ secrets.ORGANIZATION }}
3636
PR_BODY: your text goes here
37+
HOURS_DELAY: 24
3738
```
3839
- Be sure to fill out the `env` values above with your information. More info on creating secrets can be found [here](https://docs.github.com/en/actions/security-guides/encrypted-secrets).
39-
- Your GitHub token will need to have read/write access to all the repositories in the organization
40+
- Your GitHub token will need to have read/write access to all the repositories in the organization as well as the workflow permission
41+
- You must include the `HOURS_DELAY` value and set it to a valid `int` in order to set what date the action is looking for new repositories on.
42+
This being configurable allows users to give more time for repositories to contain code by increasing the delay.
43+
The default 24 will make the action check for repos created on the previous day to see if they have code scanning enabled.
44+
Changing the value to 72, will make the action check for repositories created 3 days ago.
4045

4146
## How it does this
4247
- A CRON job on GitHub actions triggers a nightly run of this script
@@ -46,6 +51,16 @@ jobs:
4651
## Contributions
4752
We would :heart: contributions to improve this action. Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for how to get involved.
4853

54+
## Debugging in GitHub Actions
55+
- Add the following lines to the workflow .yaml file
56+
```yaml
57+
env:
58+
ACTIONS_RUNNER_DEBUG: true
59+
ACTIONS_STEP_DEBUG: true
60+
```
61+
- That will enable debug printing to the action log so that you can see detailed information if issues arise.
62+
- Setting the `HOURS_DELAY: 0` is helpful so that you can create a repository in an org and not wait to test the action against it
63+
4964
## Instructions to run locally
5065
- Clone the repository
5166
- Create a personal access token with repository permissions and workflow permissions

action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---
22
name: 'Advanced-Security-Enforcer'
33
author: 'zkoppert'
4-
description: 'A GitHub Action to check for new repositories and open pull requests in the new repositories for code scanning.'
4+
description: 'A GitHub Action to check for new repositories and open pull
5+
requests in the new repositories for code scanning.'
56
runs:
67
using: 'docker'
78
image: 'docker://ghcr.io/zkoppert/advanced-security-enforcer:v1'

codeql.yml

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
---
12
name: "CodeQL"
23

34
on:
45
push:
5-
branches: [ master ]
6+
branches: [master]
67
pull_request:
78
# The branches below must be a subset of the branches above
8-
branches: [ master ]
9+
branches: [master]
910
schedule:
1011
- cron: '27 2 * * 1'
1112

@@ -15,32 +16,38 @@ jobs:
1516
runs-on: ubuntu-latest
1617

1718
steps:
18-
- name: Checkout repository
19-
uses: actions/checkout@v2
20-
21-
# Initializes the CodeQL tools for scanning.
22-
- name: Initialize CodeQL
23-
uses: github/codeql-action/init@v1
24-
# If you wish to specify custom queries, you can do so here or in a config file.
25-
# By default, queries listed here will override any specified in a config file.
26-
# Prefix the list here with "+" to use these queries and those in the config file.
19+
- name: Checkout repository
20+
uses: actions/checkout@v2
21+
22+
# Initializes the CodeQL tools for scanning.
23+
- name: Initialize CodeQL
24+
uses: github/codeql-action/init@v1
25+
# If you wish to specify custom queries,
26+
# you can do so here or in a config file.
27+
# By default, queries listed here will
28+
# override any specified in a config file.
29+
# Prefix the list here with "+" to use
30+
# these queries and those in the config file.
2731
# queries: ./path/to/local/query, your-org/your-repo/queries@main
2832

29-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
30-
# If this step fails, then you should remove it and run the build manually (see below)
31-
- name: Autobuild
32-
uses: github/codeql-action/autobuild@v1
33+
# Autobuild attempts to build any compiled
34+
# languages (C/C++, C#, or Java).
35+
# If this step fails,
36+
# then you should remove it and run the build manually (see below)
37+
- name: Autobuild
38+
uses: github/codeql-action/autobuild@v1
3339

34-
# ℹ️ Command-line programs to run using the OS shell.
35-
# 📚 https://git.io/JvXDl
40+
# ℹ️ Command-line programs to run using the OS shell.
41+
# 📚 https://git.io/JvXDl
3642

37-
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
38-
# and modify them (or add more) to build your code if your project
39-
# uses a compiled language
43+
# ✏️ If the Autobuild fails above,
44+
# remove it and uncomment the following three lines
45+
# and modify them (or add more) to build your code
46+
# if your project uses a compiled language
4047

41-
#- run: |
42-
# make bootstrap
43-
# make release
48+
#- run: |
49+
# make bootstrap
50+
# make release
4451

45-
- name: Perform CodeQL Analysis
46-
uses: github/codeql-action/analyze@v1
52+
- name: Perform CodeQL Analysis
53+
uses: github/codeql-action/analyze@v1

0 commit comments

Comments
 (0)