Skip to content
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

Release v1.4.1 #2263

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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

This file was deleted.

2 changes: 1 addition & 1 deletion remediation/dependabot/dependabotconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func UpdateDependabotConfig(dependabotConfig string) (*UpdateDependabotConfigRes
for _, Update := range updateDependabotConfigRequest.Ecosystems {
updateAlreadyExist := false
for _, update := range configMetadata.Updates {
if update.PackageEcosystem == Update.PackageEcosystem && update.Directory == Update.Directory {
if update.PackageEcosystem == Update.PackageEcosystem && (update.Directory == Update.Directory || update.Directory == Update.Directory+"/") {
updateAlreadyExist = true
break
}
Expand Down
5 changes: 5 additions & 0 deletions remediation/dependabot/dependabotconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func TestConfigDependabotFile(t *testing.T) {
Ecosystems: []Ecosystem{{"npm", "/sample", "daily"}},
isChanged: true,
},
{
fileName: "extra-slash.yml",
Ecosystems: []Ecosystem{{"npm", "/sample", "daily"}},
isChanged: false,
},
}

for _, test := range tests {
Expand Down
7 changes: 7 additions & 0 deletions testfiles/dependabotfiles/input/extra-slash.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "npm"
# Files stored in `app` directory
directory: "/sample/"
Copy link
Contributor

Choose a reason for hiding this comment

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

[High]Use a relative file path instead of an absolute path

The current configuration is using an absolute path for the 'directory' field, which could cause problems when this configuration is deployed to different environments. Replace the absolute path in the 'directory' field with a relative path.

schedule:
interval: "daily"
7 changes: 7 additions & 0 deletions testfiles/dependabotfiles/output/extra-slash.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "npm"
Copy link
Contributor

Choose a reason for hiding this comment

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

[Low]Use semantically meaningful names for variables and fields

Descriptive and context-specific names for variables and fields make the code easy to understand and maintain. Rename the field/package to reflect its role in the module

# Files stored in `app` directory
directory: "/sample/"
Copy link
Contributor

Choose a reason for hiding this comment

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

[High]Avoid using absolute paths for directories in pipelines

Using absolute paths in pipelines is error-prone, especially when the pipeline is shared or transferred across different systems. Use relative paths instead of absolute paths while defining directories in pipelines. Consider documenting the directory structure and path dependencies clearly.

schedule:
interval: "daily"