Skip to content

feat: check for api key expiration date#3049

Merged
Codelax merged 4 commits intoscaleway:masterfrom
Codelax:feat/check-api-key-expiration
Apr 21, 2023
Merged

feat: check for api key expiration date#3049
Codelax merged 4 commits intoscaleway:masterfrom
Codelax:feat/check-api-key-expiration

Conversation

@Codelax
Copy link
Member

@Codelax Codelax commented Apr 20, 2023

Closes #2648

Checks example:

A new version of scw is available (2.14.0), beware that you are currently running 2.13.0
Current api key expires in 32m43s

@Codelax Codelax self-assigned this Apr 20, 2023
@Codelax Codelax marked this pull request as draft April 20, 2023 13:25
delete(i.Request.Headers, "x-auth-token")
delete(i.Request.Headers, "X-Auth-Token")
i.Request.URL = regexp.MustCompile("organization_id=[0-9a-f-]{36}").ReplaceAllString(i.Request.URL, "organization_id=11111111-1111-1111-1111-111111111111")
i.Request.URL = regexp.MustCompile(`api\.scaleway\.com/account/v1/tokens/[0-9a-f-]{36}`).ReplaceAllString(i.Request.URL, "api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111")

Check failure

Code scanning / CodeQL

Missing regular expression anchor

When this is used as a regular expression on a URL, it may match anywhere, and arbitrary hosts may come before or after it.
delete(i.Request.Headers, "X-Auth-Token")
i.Request.URL = regexp.MustCompile("organization_id=[0-9a-f-]{36}").ReplaceAllString(i.Request.URL, "organization_id=11111111-1111-1111-1111-111111111111")
i.Request.URL = regexp.MustCompile(`api\.scaleway\.com/account/v1/tokens/[0-9a-f-]{36}`).ReplaceAllString(i.Request.URL, "api.scaleway.com/account/v1/tokens/11111111-1111-1111-1111-111111111111")
i.Request.URL = regexp.MustCompile(`api\.scaleway\.com/iam/v1alpha1/api-keys/SCW[0-9A-Z]{17}`).ReplaceAllString(i.Request.URL, "api.scaleway.com/iam/v1alpha1/api-keys/SCWXXXXXXXXXXXXXXXXX")

Check failure

Code scanning / CodeQL

Missing regular expression anchor

When this is used as a regular expression on a URL, it may match anywhere, and arbitrary hosts may come before or after it.
@codecov-commenter
Copy link

codecov-commenter commented Apr 21, 2023

Codecov Report

Attention: Patch coverage is 59.61538% with 42 lines in your changes missing coverage. Please review.

Project coverage is 75.75%. Comparing base (45caf45) to head (195dce7).
Report is 1175 commits behind head on master.

Files with missing lines Patch % Lines
internal/core/testing_recorder.go 41.66% 18 Missing and 3 partials ⚠️
internal/core/checks.go 68.25% 14 Missing and 6 partials ⚠️
internal/namespaces/autocomplete/autocomplete.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3049      +/-   ##
==========================================
+ Coverage   75.56%   75.75%   +0.19%     
==========================================
  Files         166      168       +2     
  Lines       36476    36513      +37     
==========================================
+ Hits        27563    27662      +99     
+ Misses       7962     7891      -71     
- Partials      951      960       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Codelax Codelax marked this pull request as ready for review April 21, 2023 09:36
return err
}
if !*UpdateCassettes {
apiKey.AccessKey = "SCWXXXXXXXXXXXXXXXXX"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is not the scope of this PR but just to add a note, this should be a constant as it's used a lot in the codebase. Same for 11111111-1111-1111-1111-111111111111 in place of project/organization id.

@Codelax Codelax added this pull request to the merge queue Apr 21, 2023
Merged via the queue into scaleway:master with commit b079d8d Apr 21, 2023
@Codelax Codelax deleted the feat/check-api-key-expiration branch April 21, 2023 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IAM: show warning when API key is about to expire

3 participants