add semgrep rules

This commit is contained in:
iacore
2024-02-10 12:50:38 +00:00
parent c141e661f0
commit 81aa9c1b6b
2 changed files with 24 additions and 4 deletions
+4 -4
View File
@@ -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
}
+20
View File
@@ -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, ...)