-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(server): expose endpoint for certificates enumeration (j#IS-2824)
- Loading branch information
1 parent
26d7708
commit c43b530
Showing
7 changed files
with
142 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package server | ||
|
||
import ( | ||
"github.com/gofiber/fiber/v2" | ||
"github.com/rs/zerolog/log" | ||
"gitlab.rete.farm/sistemi/inca/pki" | ||
) | ||
|
||
func (inca *Inca) handlerEnum(c *fiber.Ctx) error { | ||
filter := c.Params("filter", ".*") | ||
results, err := (*inca.Cfg.Storage).Find(filter) | ||
if err != nil { | ||
log.Error().Err(err).Msg("unable to enumerate certificates") | ||
return c.SendStatus(fiber.StatusInternalServerError) | ||
} | ||
|
||
crts := []Crt{} | ||
for _, result := range results { | ||
crt, err := pki.ParseBytes(result) | ||
if err != nil { | ||
log.Error().Err(err).Msg("unable to parse certificate") | ||
} | ||
crts = append(crts, EncodeCrt(crt)) | ||
} | ||
|
||
return c.JSON(struct { | ||
Results []Crt `json:"results"` | ||
}{crts}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package util | ||
|
||
import "regexp" | ||
|
||
func RegexesMatch(payload string, regexes ...string) bool { | ||
match := true | ||
for _, filter := range regexes { | ||
match = match && ErrWrap(false)(regexp.MatchString(filter, payload)) | ||
} | ||
return match | ||
} |