diff --git a/Dockerfile-repochecker b/Dockerfile-repochecker index df49d0cb..8f74b1ad 100644 --- a/Dockerfile-repochecker +++ b/Dockerfile-repochecker @@ -27,7 +27,7 @@ ADD https://web.archive.org/web/20240926154729if_/https://grammalecte.net/zip/Gr RUN mkdir /srv/grammalecte && cd /srv/grammalecte && unzip /srv/grammalecte.zip && sed -i 's/if sys.version_info.major < (3, 7):/if False:/' /srv/grammalecte/grammalecte-server.py -FROM alpine:3.21 +FROM alpine:3.19 ENTRYPOINT ["/usr/bin/repochecker", "--rules-plugins=/usr/lib/epita-rules.so", "--rules-plugins=/usr/lib/file-inspector.so", "--rules-plugins=/usr/lib/grammalecte-rules.so", "--rules-plugins=/usr/lib/pcap-inspector.so", "--rules-plugins=/usr/lib/videos-rules.so"] diff --git a/admin/api/exercice.go b/admin/api/exercice.go index 1df894bd..afe6b8d7 100644 --- a/admin/api/exercice.go +++ b/admin/api/exercice.go @@ -953,6 +953,23 @@ func updateExerciceFlag(c *gin.Context) { flag.Help = uk.Help flag.IgnoreCase = uk.IgnoreCase flag.Multiline = uk.Multiline + flag.ChoicesCost = uk.ChoicesCost + flag.BonusGain = uk.BonusGain + + if uk.CaptureRe != nil && len(*uk.CaptureRe) > 0 { + if flag.CaptureRegexp != uk.CaptureRe && uk.Flag == "" { + c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": "Pour changer la capture_regexp, vous devez rentrer la réponse attendue à nouveau, car le flag doit être recalculé."}) + return + } + flag.CaptureRegexp = uk.CaptureRe + } else { + if flag.CaptureRegexp != nil && uk.Flag == "" { + c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": "Pour changer la capture_regexp, vous devez rentrer la réponse attendue à nouveau, car le flag doit être recalculé."}) + return + } + flag.CaptureRegexp = nil + } + if len(uk.Flag) > 0 { var err error flag.Checksum, err = flag.ComputeChecksum([]byte(uk.Flag)) @@ -964,14 +981,6 @@ func updateExerciceFlag(c *gin.Context) { } else { flag.Checksum = uk.Value } - flag.ChoicesCost = uk.ChoicesCost - flag.BonusGain = uk.BonusGain - - if uk.CaptureRe != nil && len(*uk.CaptureRe) > 0 { - flag.CaptureRegexp = uk.CaptureRe - } else { - flag.CaptureRegexp = nil - } if _, err := flag.Update(); err != nil { log.Println("Unable to updateExerciceFlag:", err.Error()) diff --git a/admin/api/password.go b/admin/api/password.go index 349f65e5..1941df38 100644 --- a/admin/api/password.go +++ b/admin/api/password.go @@ -34,6 +34,11 @@ func declarePasswordRoutes(router *gin.RouterGroup) { c.JSON(http.StatusOK, gin.H{"password": passwd}) }) + router.GET("/oauth-status", func(c *gin.Context) { + c.JSON(http.StatusOK, gin.H{ + "secret_defined": OidcSecret != "", + }) + }) router.GET("/dex.yaml", func(c *gin.Context) { cfg, err := genDexConfig() if err != nil { diff --git a/admin/api/team.go b/admin/api/team.go index 2d85ca95..a0bea3bd 100644 --- a/admin/api/team.go +++ b/admin/api/team.go @@ -1,6 +1,7 @@ package api import ( + "encoding/json" "fmt" "log" "net/http" @@ -294,6 +295,11 @@ func bindingTeams(c *gin.Context) { c.String(http.StatusOK, ret) } +type teamAssociation struct { + Association string `json:"association"` + TeamId int64 `json:"team_id"` +} + func allAssociations(c *gin.Context) { teams, err := fic.GetTeams() if err != nil { @@ -302,7 +308,7 @@ func allAssociations(c *gin.Context) { return } - var ret []string + var ret []teamAssociation for _, team := range teams { assocs, err := pki.GetTeamAssociations(TeamsDir, team.Id) @@ -312,7 +318,7 @@ func allAssociations(c *gin.Context) { } for _, a := range assocs { - ret = append(ret, a) + ret = append(ret, teamAssociation{a, team.Id}) } } @@ -320,8 +326,21 @@ func allAssociations(c *gin.Context) { } func importTeamsFromCyberrange(c *gin.Context) { + file, err := c.FormFile("file") + if err != nil { + c.JSON(http.StatusBadRequest, gin.H{"errmsg": "Failed to get file: " + err.Error()}) + return + } + + src, err := file.Open() + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"errmsg": "Failed to open file: " + err.Error()}) + return + } + defer src.Close() + var ut []fic.CyberrangeTeam - err := c.ShouldBindJSON(&fic.CyberrangeAPIResponse{Data: &ut}) + err = json.NewDecoder(src).Decode(&fic.CyberrangeAPIResponse{Data: &ut}) if err != nil { c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": err.Error()}) return diff --git a/admin/index.go b/admin/index.go index fa457641..506ff805 100644 --- a/admin/index.go +++ b/admin/index.go @@ -4,7 +4,7 @@ const indextpl = `
-