Skip to content

Commit

Permalink
fix(api): avoid division by zero in list size (#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba authored Sep 7, 2024
1 parent 5a465ec commit 5c9dc8a
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/router/file_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ func (r *FileRouter) List(c *fiber.Ctx) error {
return err
}
}
if size == 0 {
return errorpkg.NewInvalidQueryParamError("size")
}
sortBy := c.Query("sort_by")
if !IsValidSortBy(sortBy) {
return errorpkg.NewInvalidQueryParamError("sort_by")
Expand Down
3 changes: 3 additions & 0 deletions api/router/group_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ func (r *GroupRouter) List(c *fiber.Ctx) error {
return err
}
}
if size == 0 {
return errorpkg.NewInvalidQueryParamError("size")
}
sortBy := c.Query("sort_by")
if !IsValidSortBy(sortBy) {
return errorpkg.NewInvalidQueryParamError("sort_by")
Expand Down
3 changes: 3 additions & 0 deletions api/router/insights_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ func (r *InsightsRouter) ListEntities(c *fiber.Ctx) error {
return err
}
}
if size == 0 {
return errorpkg.NewInvalidQueryParamError("size")
}
sortBy := c.Query("sort_by")
if !IsValidSortBy(sortBy) {
return errorpkg.NewInvalidQueryParamError("sort_by")
Expand Down
6 changes: 6 additions & 0 deletions api/router/invitation_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ func (r *InvitationRouter) GetIncoming(c *fiber.Ctx) error {
return err
}
}
if size == 0 {
return errorpkg.NewInvalidQueryParamError("size")
}
sortBy := c.Query("sort_by")
if !IsValidSortBy(sortBy) {
return errorpkg.NewInvalidQueryParamError("sort_by")
Expand Down Expand Up @@ -184,6 +187,9 @@ func (r *InvitationRouter) GetOutgoing(c *fiber.Ctx) error {
return err
}
}
if size == 0 {
return errorpkg.NewInvalidQueryParamError("size")
}
sortBy := c.Query("sort_by")
if !IsValidSortBy(sortBy) {
return errorpkg.NewInvalidQueryParamError("sort_by")
Expand Down
3 changes: 3 additions & 0 deletions api/router/organization_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ func (r *OrganizationRouter) List(c *fiber.Ctx) error {
return err
}
}
if size == 0 {
return errorpkg.NewInvalidQueryParamError("size")
}
sortBy := c.Query("sort_by")
if !IsValidSortBy(sortBy) {
return errorpkg.NewInvalidQueryParamError("sort_by")
Expand Down
3 changes: 3 additions & 0 deletions api/router/snapshot_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ func (r *SnapshotRouter) List(c *fiber.Ctx) error {
return err
}
}
if size == 0 {
return errorpkg.NewInvalidQueryParamError("size")
}
sortBy := c.Query("sort_by")
if !IsValidSortBy(sortBy) {
return errorpkg.NewInvalidQueryParamError("sort_by")
Expand Down
3 changes: 3 additions & 0 deletions api/router/task_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ func (r *TaskRouter) List(c *fiber.Ctx) error {
return err
}
}
if size == 0 {
return errorpkg.NewInvalidQueryParamError("size")
}
sortBy := c.Query("sort_by")
if !IsValidSortBy(sortBy) {
return errorpkg.NewInvalidQueryParamError("sort_by")
Expand Down
3 changes: 3 additions & 0 deletions api/router/user_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ func (r *UserRouter) List(c *fiber.Ctx) error {
return err
}
}
if size == 0 {
return errorpkg.NewInvalidQueryParamError("size")
}
sortBy := c.Query("sort_by")
if !IsValidSortBy(sortBy) {
return errorpkg.NewInvalidQueryParamError("sort_by")
Expand Down
3 changes: 3 additions & 0 deletions api/router/workspace_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ func (r *WorkspaceRouter) List(c *fiber.Ctx) error {
return err
}
}
if size == 0 {
return errorpkg.NewInvalidQueryParamError("size")
}
sortBy := c.Query("sort_by")
if !IsValidSortBy(sortBy) {
return errorpkg.NewInvalidQueryParamError("sort_by")
Expand Down

0 comments on commit 5c9dc8a

Please sign in to comment.