Skip to content

Conversation

@gireesh-naidu
Copy link
Contributor

@gireesh-naidu gireesh-naidu commented Nov 3, 2022

Description

External links can now be configured at cluster level and app level.
Fixes #1991

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Tested for Create,update,put and post operations for applevel and clusterlevel links.
  • Tested above operations for all the user roles.

Checklist:

  • The title of the PR states what changed and the related issues number (used for the release note).
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have tested it for all user roles
  • I have added all the required unit/api test cases

@gireesh-naidu gireesh-naidu added the enhancement New feature or request label Nov 3, 2022
@gireesh-naidu gireesh-naidu self-assigned this Nov 3, 2022
@gireesh-naidu gireesh-naidu marked this pull request as ready for review November 3, 2022 08:08
@gitguardian
Copy link

gitguardian bot commented Nov 24, 2022

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id Secret Commit Filename
141558 Generic High Entropy Secret 2693b86 scripts/devtron-reference-helm-charts/reference-chart_4-16-0/env-values.yaml View secret
2763127 Generic High Entropy Secret 2693b86 scripts/devtron-reference-helm-charts/reference-chart_4-16-0/secrets-test-values.yaml View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

token := r.Header.Get("token")
if v.Has("appId") {
id, err := strconv.Atoi(appId)
if err != nil {
Copy link
Contributor

@kripanshdevtron kripanshdevtron Nov 25, 2022

Choose a reason for hiding this comment

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

err is not logged

}
}
id, err := strconv.Atoi(clusterId)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

error is not logged and handled properly

return
}
}
id, err := strconv.Atoi(clusterId)
Copy link
Contributor

@kripanshdevtron kripanshdevtron Nov 25, 2022

Choose a reason for hiding this comment

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

refactor id field correctly

ClusterId: 0,
}
res, err := impl.externalLinkService.FetchAllActiveLinksByLinkIdentifier(linkIdentifier, id, externalLink.ADMIN_ROLE, int(userId))
if err != nil && err != pg.ErrNoRows {
Copy link
Contributor

@kripanshdevtron kripanshdevtron Nov 25, 2022

Choose a reason for hiding this comment

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

this error should not get propagated here, it should have been handled in dbLayer.

linkId, err := strconv.Atoi(id)
if err != nil {
impl.logger.Errorw("request err, DeleteExternalLink", "err", err, "id", id)
impl.logger.Errorw("request err, DeleteExternalLink", "id", id)
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we not logging error here??

func (impl AppListingRepositoryImpl) FetchAllActiveDevtronAppsWithAppIdAndName() ([]AppNameTypeIdContainerDBResponse, error) {
impl.Logger.Debug("reached at Fetch All Active Devtron Apps With AppId And Name:")
var apps []AppNameTypeIdContainerDBResponse
query := "select id,app_name " + "from app where app_store=false and active=true;"
Copy link
Contributor

Choose a reason for hiding this comment

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

convert this query to ORM query.

var apps []AppNameTypeIdContainerDBResponse
query := "select installed_apps.id,app.app_name " + "from app INNER JOIN installed_apps on app.id = installed_apps.app_id where app.active=true;"
_, err := impl.dbConnection.Query(&apps, query)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

noRows error handling missing

var apps []AppNameTypeIdContainerDBResponse
query := "select id,app_name " + "from app where app_store=false and active=true;"
_, err := impl.dbConnection.Query(&apps, query)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

no rows error handling missing


func (impl ExternalLinkIdentifierMappingRepositoryImpl) UpdateAllActiveToInActive(Id int, tx *pg.Tx) error {

query := "UPDATE external_link_identifier_mapping " +
Copy link
Contributor

Choose a reason for hiding this comment

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

replace this with ORM query

}
return records, nil
}
func (impl ExternalLinkServiceImpl) FetchAllActiveLinksByLinkIdentifier(linkIdentifier *LinkIdentifier, clusterId int, userRole string, userId int) ([]*ExternalLinkDto, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

userRole and userId are not used, we need to clean this

Type: -1,
ClusterId: 0,
})
expectedResultLinks := make([]externalLink.ExternalLinkDto, 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

expectedResultLinks should be made using mockLinks or mockGlobLinks

@kripanshdevtron kripanshdevtron changed the title External links extention External links extention for app level Nov 26, 2022
@gireesh-naidu gireesh-naidu merged commit 4c31141 into main Nov 26, 2022
@gireesh-naidu gireesh-naidu deleted the external_links_extention branch November 26, 2022 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

External links should support configurable links for each app

3 participants