Skip to content

Commit 8fbdd88

Browse files
sync: Main sync develop (#6548)
* fix: rest handler missing return statements * vendor update develop --------- Co-authored-by: Ash-exp <asutosh2000ad@gmail.com>
1 parent aa8800b commit 8fbdd88

17 files changed

+42
-10
lines changed

api/appStore/deployment/AppStoreDeploymentRestHandler.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ func (handler AppStoreDeploymentRestHandlerImpl) UpdateProjectHelmApp(w http.Res
539539
if err != nil {
540540
handler.Logger.Errorw("error in decoding app id", "err", err)
541541
common.WriteJsonResp(w, err, "error in decoding app id", http.StatusBadRequest)
542+
return
542543
}
543544
// this rbac object checks that whether user have permission to change current project.
544545
rbacObjectForCurrentProject, rbacObjectForCurrentProject2 := handler.enforcerUtilHelm.GetHelmObjectByClusterIdNamespaceAndAppName(appIdentifier.ClusterId, appIdentifier.Namespace, appIdentifier.ReleaseName)
@@ -555,6 +556,7 @@ func (handler AppStoreDeploymentRestHandlerImpl) UpdateProjectHelmApp(w http.Res
555556
if err != nil {
556557
handler.Logger.Errorw("service err, InstalledAppId", "err", err, "InstalledAppId", request.InstalledAppId)
557558
common.WriteJsonResp(w, fmt.Errorf("Unable to fetch installed app details"), nil, http.StatusBadRequest)
559+
return
558560
}
559561
if installedApp.IsVirtualEnvironment {
560562
rbacObjectForCurrentProject, _ := handler.enforcerUtilHelm.GetAppRBACNameByInstalledAppId(request.InstalledAppId)
@@ -580,8 +582,10 @@ func (handler AppStoreDeploymentRestHandlerImpl) UpdateProjectHelmApp(w http.Res
580582
if err != nil {
581583
handler.Logger.Errorw("error in updating project for helm apps", "err", err)
582584
common.WriteJsonResp(w, err, "error in updating project", http.StatusBadRequest)
585+
return
583586
} else {
584587
handler.Logger.Errorw("Helm App project update")
585588
common.WriteJsonResp(w, nil, "Project Updated", http.StatusOK)
589+
return
586590
}
587591
}

api/appStore/deployment/CommonDeploymentRestHandler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ func (handler *CommonDeploymentRestHandlerImpl) RollbackApplication(w http.Respo
268268
appOfferingMode, installedAppDto, err := handler.getAppOfferingMode(installedAppId, *request.HAppId)
269269
if err != nil {
270270
common.WriteJsonResp(w, err, "bad request", http.StatusBadRequest)
271+
return
271272
}
272273
installedAppDto.UserId = userId
273274
//rbac block starts from here

api/auth/user/UserAuthHandler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ func (handler UserAuthHandlerImpl) LoginHandler(w http.ResponseWriter, r *http.R
7070
if err != nil {
7171
handler.logger.Errorw("request err, LoginHandler", "err", err, "payload", up)
7272
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
73+
return
7374
}
7475

7576
err = handler.validator.Struct(up)

api/helm-app/HelmAppRestHandler.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ func (handler *HelmAppRestHandlerImpl) Hibernate(w http.ResponseWriter, r *http.
191191
appType, err = strconv.Atoi(appTypeString)
192192
if err != nil {
193193
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
194+
return
194195
}
195196
}
196197

@@ -282,6 +283,7 @@ func (handler *HelmAppRestHandlerImpl) UnHibernate(w http.ResponseWriter, r *htt
282283
appType, err = strconv.Atoi(appTypeString)
283284
if err != nil {
284285
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
286+
return
285287
}
286288
}
287289
token := r.Header.Get("token")

api/k8s/application/k8sApplicationRestHandler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ func (handler *K8sApplicationRestHandlerImpl) requestValidationAndRBAC(w http.Re
729729
if err != nil {
730730
handler.logger.Errorw(bean2.AppIdDecodingError, "err", err, "appIdentifier", request.AppIdentifier)
731731
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
732+
return
732733
}
733734
valid, err := handler.argoApplicationReadService.ValidateArgoResourceRequest(r.Context(), appIdentifier, request.K8sRequest)
734735
if err != nil || !valid {

api/restHandler/BatchOperationRestHandler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ func (handler BatchOperationRestHandlerImpl) Operate(w http.ResponseWriter, r *h
9494

9595
if workflow.Destination.App == nil || len(*workflow.Destination.App) == 0 {
9696
common.WriteJsonResp(w, errors.New("app name cannot be empty"), nil, http.StatusBadRequest)
97+
return
9798
}
9899
rbacString := handler.enforcerUtil.GetProjectAdminRBACNameBYAppName(*workflow.Destination.App)
99100
if ok := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionCreate, rbacString); !ok {

api/restHandler/BulkUpdateRestHandler.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,22 +183,26 @@ func (handler BulkUpdateRestHandlerImpl) GetImpactedAppsName(w http.ResponseWrit
183183
ok := handler.CheckAuthForImpactedObjects(deploymentTemplateImpactedApp.AppId, deploymentTemplateImpactedApp.EnvId, appResourceObjects, envResourceObjects, token)
184184
if !ok {
185185
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
186+
return
186187
}
187188
}
188189
for _, configMapImpactedApp := range impactedApps.ConfigMap {
189190
ok := handler.CheckAuthForImpactedObjects(configMapImpactedApp.AppId, configMapImpactedApp.EnvId, appResourceObjects, envResourceObjects, token)
190191
if !ok {
191192
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
193+
return
192194
}
193195
}
194196
for _, secretImpactedApp := range impactedApps.Secret {
195197
ok := handler.CheckAuthForImpactedObjects(secretImpactedApp.AppId, secretImpactedApp.EnvId, appResourceObjects, envResourceObjects, token)
196198
if !ok {
197199
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
200+
return
198201
}
199202
}
200203
common.WriteJsonResp(w, err, impactedApps, http.StatusOK)
201204
}
205+
202206
func (handler BulkUpdateRestHandlerImpl) CheckAuthForBulkUpdate(AppId int, EnvId int, AppName string, rbacObjects map[int]string, token string) bool {
203207
resourceName := rbacObjects[AppId]
204208
if ok := handler.enforcer.Enforce(token, casbin.ResourceApplications, casbin.ActionUpdate, resourceName); !ok {
@@ -243,18 +247,21 @@ func (handler BulkUpdateRestHandlerImpl) BulkUpdate(w http.ResponseWriter, r *ht
243247
ok := handler.CheckAuthForBulkUpdate(deploymentTemplateImpactedApp.AppId, deploymentTemplateImpactedApp.EnvId, deploymentTemplateImpactedApp.AppName, rbacObjects, token)
244248
if !ok {
245249
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
250+
return
246251
}
247252
}
248253
for _, configMapImpactedApp := range impactedApps.ConfigMap {
249254
ok := handler.CheckAuthForBulkUpdate(configMapImpactedApp.AppId, configMapImpactedApp.EnvId, configMapImpactedApp.AppName, rbacObjects, token)
250255
if !ok {
251256
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
257+
return
252258
}
253259
}
254260
for _, secretImpactedApp := range impactedApps.Secret {
255261
ok := handler.CheckAuthForBulkUpdate(secretImpactedApp.AppId, secretImpactedApp.EnvId, secretImpactedApp.AppName, rbacObjects, token)
256262
if !ok {
257263
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
264+
return
258265
}
259266
}
260267
isSuperAdmin := handler.enforcer.Enforce(token, casbin.ResourceGlobal, casbin.ActionCreate, "*")

api/restHandler/GitOpsConfigRestHandler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ func (impl GitOpsConfigRestHandlerImpl) GitOpsValidator(w http.ResponseWriter, r
312312
if err != nil && !errors.Is(err, moduleErr.ModuleNotFoundError) {
313313
impl.logger.Errorw("error in getting argo module", "error", err)
314314
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
315+
return
315316
}
316317
detailedErrorGitOpsConfigResponse := impl.gitOpsConfigService.GitOpsValidateDryRun(argoModule.IsInstalled(), &bean)
317318
common.WriteJsonResp(w, nil, detailedErrorGitOpsConfigResponse, http.StatusOK)

api/restHandler/ImageScanRestHandler.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ func (impl ImageScanRestHandlerImpl) FetchExecutionDetail(w http.ResponseWriter,
198198
if err != nil {
199199
impl.logger.Errorw("request err, FetchExecutionDetail", "err", err, "imageScanDeployInfoIdS", imageScanDeployInfoIdS)
200200
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
201+
return
201202
}
202203
}
203204
artifactIdS := v.Get("artifactId")
@@ -206,6 +207,7 @@ func (impl ImageScanRestHandlerImpl) FetchExecutionDetail(w http.ResponseWriter,
206207
if err != nil {
207208
impl.logger.Errorw("request err, FetchExecutionDetail", "err", err, "artifactIdS", artifactIdS)
208209
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
210+
return
209211
}
210212
}
211213
appIds := v.Get("appId")
@@ -214,6 +216,7 @@ func (impl ImageScanRestHandlerImpl) FetchExecutionDetail(w http.ResponseWriter,
214216
if err != nil {
215217
impl.logger.Errorw("request err, FetchExecutionDetail", "err", err, "appIds", appIds)
216218
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
219+
return
217220
}
218221
}
219222
envIds := v.Get("envId")
@@ -222,6 +225,7 @@ func (impl ImageScanRestHandlerImpl) FetchExecutionDetail(w http.ResponseWriter,
222225
if err != nil {
223226
impl.logger.Errorw("request err, FetchExecutionDetail", "err", err, "envIds", envIds)
224227
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
228+
return
225229
}
226230
}
227231
image := v.Get("image")
@@ -266,6 +270,7 @@ func (impl ImageScanRestHandlerImpl) FetchExecutionDetail(w http.ResponseWriter,
266270
}
267271
} else {
268272
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
273+
return
269274
}
270275
//RBAC
271276
} else {
@@ -285,6 +290,7 @@ func (impl ImageScanRestHandlerImpl) FetchMinScanResultByAppIdAndEnvId(w http.Re
285290
if err != nil {
286291
impl.logger.Errorw("request err, FetchMinScanResultByAppIdAndEnvId", "err", err, "appIds", appIds)
287292
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
293+
return
288294
}
289295
request.AppId = appId
290296
}
@@ -294,6 +300,7 @@ func (impl ImageScanRestHandlerImpl) FetchMinScanResultByAppIdAndEnvId(w http.Re
294300
if err != nil {
295301
impl.logger.Errorw("request err, FetchMinScanResultByAppIdAndEnvId", "err", err, "envIds", envIds)
296302
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
303+
return
297304
}
298305
request.EnvId = envId
299306
}

api/restHandler/PolicyRestHandler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ func (impl PolicyRestHandlerImpl) GetPolicy(w http.ResponseWriter, r *http.Reque
218218
if err != nil {
219219
impl.logger.Errorw("request err, GetPolicy", "err", err, "id", id)
220220
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
221+
return
221222
}
222223
req.Id = ids
223224
}

0 commit comments

Comments
 (0)