diff --git a/core/webapi/user.go b/core/webapi/user.go index 84bc524..42b0d90 100644 --- a/core/webapi/user.go +++ b/core/webapi/user.go @@ -45,7 +45,7 @@ func (s *User) ParseSocial() { _ = json.Unmarshal(s.SocialRaw, &s.Social) } -func GetFrequentTags(ids string) ([]FrequentTag, error) { +func GetFrequentTags(c *fiber.Ctx, ids string) ([]FrequentTag, error) { var tags []FrequentTag URL := http.GetFrequentTagsURL(ids) @@ -97,7 +97,7 @@ func GetUserArtworks(c *fiber.Ctx, id, ids string) ([]ArtworkBrief, error) { return works, nil } -func GetUserArtworksID(id, category string, page int) (string, int, error) { +func GetUserArtworksID(c *fiber.Ctx, id, category string, page int) (string, int, error) { URL := http.GetUserArtworksURL(id) resp, err := http.UnwrapWebAPIRequest(URL, "") @@ -189,7 +189,7 @@ func GetUserArtwork(c *fiber.Ctx, id, category string, page int) (User, error) { } if category != "bookmarks" { - ids, count, err := GetUserArtworksID(id, category, page) + ids, count, err := GetUserArtworksID(c, id, category, page) if err != nil { return user, err } @@ -209,7 +209,7 @@ func GetUserArtwork(c *fiber.Ctx, id, category string, page int) (User, error) { }) user.Artworks = works - user.FrequentTags, err = GetFrequentTags(ids) + user.FrequentTags, err = GetFrequentTags(c, ids) if err != nil { return user, err } diff --git a/semgrep.yml b/semgrep.yml new file mode 100644 index 0000000..e825321 --- /dev/null +++ b/semgrep.yml @@ -0,0 +1,20 @@ +# Usage: semgrep scan -f semgrep.yml +rules: +- id: rule-0 + message: "find http requests made not with *fiber.Ctx available" + languages: [go] + severity: WARNING + patterns: + - pattern: | + http.$HFUNC(URL, ...) + - pattern-not-inside: | + func $FUNC(c *fiber.Ctx, ...) $RET { + ... + } +- id: rule-1 + message: "find http requests made (limiter should be installed at all places)" + languages: [go] + severity: INFO + patterns: + - pattern: | + http.$HFUNC(URL, ...)