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

Add Release Bundle exists API #1066

Merged
merged 3 commits into from
Jan 12, 2025
Merged

Conversation

oshratZairi
Copy link
Contributor

@oshratZairi oshratZairi commented Dec 26, 2024

… RBV2.

  • All tests passed. If this feature is not already covered by the tests, I added new tests.
  • All static analysis checks passed.
  • This pull request is on the dev branch.
  • I used gofmt for formatting the code before submitting the pull request.

Implemented a new API endpoint to check if a release bundle exists in RBV2

Copy link
Contributor

@EyalDelarea EyalDelarea left a comment

Choose a reason for hiding this comment

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

I got a little confused if this is a check for RBV1 / V2 check, Or endpoint to check weather a release bundle exists. ( maybe it's the same meaning but i got confused )

This also effect the location of the code, if it should be on v1 or v2.
And also the name of the function, IsRV2? \ exists?

Can we clarify what is the use case and name the functions to be more clear?

conflictErrorMessage = "Bundle already exists"
ReleaseBundleImportRestApiEndpoint = "api/release/import/"
octetStream = "application/octet-stream"
ReleaseBundleExistInRbV2RestApiEndpoint = "lifecycle/api/v2/release_bundle/existence"
Copy link
Contributor

Choose a reason for hiding this comment

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

As this is a lifecycle endpoint, And RBV2 is under "lifecycle", let's move the relevant code to lifecycle-services.

It is indeed confusing because this is the code for V1.

httpClientsDetails := rs.ArtDetails.CreateHttpClientDetails()
project = "project=" + project

rtUrl := strings.Replace(rs.ArtDetails.GetUrl(), "/artifactory", "", 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Once we transition to the V2 code, we should no longer need to manually remove the Artifactory endpoint; we can simply append the new endpoint.

Copy link
Contributor

@EyalDelarea EyalDelarea left a comment

Choose a reason for hiding this comment

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

Looks good!

Please let's edit the function call & filename, and then update the README and explain each parameter even if it seems self explanatory.

isExistInRbV2Endpoint = "api/v2/release_bundle/existence"
)

func (rbs *ReleaseBundlesService) IsExists(projectName, releaseBundleNameAndVersion string) (bool, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change this to releaseBundleExists(projectName,rbName,rbVersion)?

Once it's done, update the readme with a detailed example for each parameter.

Afterward the call will look like this:

exists, err := serviceManager.releaseBundleExists(projectName,rbName,rbVersion)

README.md Outdated
@@ -232,6 +232,7 @@
- [Export Release Bundle Archive](#export-release-bundle-archive)
- [Import Release Bundle Archive](#import-release-bundle-archive)
- [Remote Delete Release Bundle](#remote-delete-release-bundle)
- [Check if Release Bundle exists in V2](#check-if-rb-exists-in-v2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- [Check if Release Bundle exists in V2](#check-if-rb-exists-in-v2)
- [Check if Release Bundle exists ](#check-rb-exists)

isExistInRbV2Endpoint = "api/v2/release_bundle/existence"
)

func (rbs *ReleaseBundlesService) ReleaseBundleExists(projectName, rbName, rbVersion string) (bool, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since projectName is optional, let change it to rbName,rbVersion,projectName

README.md Outdated
#### check-if-rb-exists-in-v2

```go

Copy link
Contributor

Choose a reason for hiding this comment

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

Please let's add a comment explaining that project is optional and can be empty.

@EyalDelarea
Copy link
Contributor

Waiting for the CLI PR to be ready to merge.

@EyalDelarea EyalDelarea changed the title Implemented a new API endpoint to check if a release bundle exists in… Add Release Bundle exists function Jan 12, 2025
@EyalDelarea EyalDelarea added new feature Automatically generated release notes improvement Automatically generated release notes safe to test Approve running integration tests on a pull request and removed new feature Automatically generated release notes labels Jan 12, 2025
@github-actions github-actions bot removed the safe to test Approve running integration tests on a pull request label Jan 12, 2025
Copy link
Contributor

🚨 Frogbot scanned this pull request and found the below:

📗 Scan Summary

  • Frogbot scanned for vulnerabilities and found 1 issues
Scan Category Status Security Issues
Software Composition Analysis ✅ Done Not Found
Contextual Analysis ✅ Done -
Static Application Security Testing (SAST) ✅ Done
1 Issues Found 1 Low
Secrets ✅ Done -
Infrastructure as Code (IaC) ✅ Done Not Found

Copy link
Contributor

{
		User: "admin",
		Auth: []ssh.AuthMethod{
			sshAuth,
		},
		//#nosec G106 -- Used to get ssh headers only.
		HostKeyCallback: ssh.InsecureIgnoreHostKey(),
	}

at auth/sshlogin.go (line 67)

🎯 Static Application Security Testing (SAST) Vulnerability

Severity Finding
low
Low
SSH key not verified properly, expired certificates may be accepted
Full description

Vulnerability Details

CWE: 322
Rule ID: go-key-past-expiration

Overview

SSH Keys Past Expiration is a vulnerability that occurs when SSH keys
used for authentication have expired. Expired keys can lead to
unauthorized access to systems and sensitive data, posing a security
risk to the organization.

Vulnerable example

package main

import (
    "golang.org/x/crypto/ssh"
    "net"
)

func main() {}

func insecureIgnoreHostKey() {
    _ = &ssh.ClientConfig{
        User:            "username",
        Auth:            []ssh.AuthMethod{nil},
        HostKeyCallback: ssh.InsecureIgnoreHostKey(),
    }
}

In this example, the InsecureIgnoreHostKey function is used to ignore
host key verification, which can lead to accepting expired or invalid
keys.

Remediation

package main

import (
    "golang.org/x/crypto/ssh"
    "net"
)

func main() {}

func secureHostKeyCallback() {
    publicKeyBytes, _ := ioutil.ReadFile("allowed_hostkey.pub")
    publicKey, _ := ssh.ParsePublicKey(publicKeyBytes)

    _ = &ssh.ClientConfig{
        User:            "username",
        Auth:            []ssh.AuthMethod{nil},
        HostKeyCallback: ssh.FixedHostKey(publicKey),
    }
}

By using allowed host keys and proper host key verification, we can
mitigate the risk of accepting expired or invalid SSH keys.



@EyalDelarea EyalDelarea changed the title Add Release Bundle exists function Add Release Bundle exists API Jan 12, 2025
@EyalDelarea EyalDelarea merged commit f3d607f into jfrog:dev Jan 12, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Automatically generated release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants