-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(updatecli): Update the expiration date in security.txt when app…
…roaching it. (#7793) * chore(updatecli): Update the expiration date in security.txt when approaching it. * WiP * fix(updatecli): Uses the right regexp.
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
# Read the date after "Expires:" | ||
expires_date=$(grep -oP 'Expires: \K.*' content/.well-known/security.txt) | ||
|
||
# Convert the expires date to seconds since epoch | ||
expires_epoch=$(date -d "$expires_date" +%s) | ||
|
||
# Get the current date in seconds since epoch | ||
current_epoch=$(date +%s) | ||
|
||
# Calculate the difference in seconds (30 days * 24 hours * 60 minutes * 60 seconds) | ||
one_month_seconds=$((30 * 24 * 60 * 60)) | ||
|
||
# Check if the current date is less than one month close to the expires date | ||
if (( current_epoch + one_month_seconds >= expires_epoch )); then | ||
# Add one year to the expires date | ||
new_expires_date=$(date -u -d "$expires_date + 1 year" +%Y-%m-%dT%H:%M:%S.000Z) | ||
echo "$new_expires_date" | ||
else | ||
echo "$expires_date" | ||
fi |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
name: Bump the expiration date in content/.well-known/security.txt when approaching the expiry date | ||
|
||
scms: | ||
default: | ||
kind: github | ||
spec: | ||
user: "{{ .github.user }}" | ||
email: "{{ .github.email }}" | ||
owner: "{{ .github.owner }}" | ||
repository: "{{ .github.repository }}" | ||
token: "{{ requiredEnv .github.token }}" | ||
username: "{{ .github.username }}" | ||
branch: "{{ .github.branch }}" | ||
|
||
sources: | ||
expirationDate: | ||
kind: shell | ||
name: "Get Expiration date from security.txt" | ||
spec: | ||
command: bash ./updatecli/scripts/update-security-txt.sh | ||
|
||
targets: | ||
updateExpiresDate: | ||
kind: file | ||
name: "Update Expires date in security.txt" | ||
spec: | ||
file: content/.well-known/security.txt | ||
matchpattern: >- | ||
Expires: .* | ||
replacepattern: >- | ||
Expires: {{ source "expirationDate" }} | ||
scmid: default | ||
|
||
actions: | ||
default: | ||
kind: github/pullrequest | ||
scmid: default | ||
title: "Update Expiration date in security.txt" | ||
spec: | ||
labels: | ||
- chore |