Skip to content

Commit

Permalink
feat(iris): limit judge result output (#2256)
Browse files Browse the repository at this point in the history
* feat(iris): limit judge result output

* feat(iris): set limit 1MB
  • Loading branch information
Jaehyeon1020 authored Dec 7, 2024
1 parent 9c6e9ef commit e92dd4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/iris/src/common/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ const (
EXCHANGE = "judger-exchange"
RESULT_KEY = "result"
)

const MAX_OUTPUT = 1048576 // 1MB
4 changes: 4 additions & 0 deletions apps/iris/src/handler/judge-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ func (j *JudgeHandler) judgeTestcase(idx int, dir string, validReq *Request,
res.SetJudgeExecResult(runResult.ExecResult)
res.Output = string(runResult.Output)

if len(res.Output) > constants.MAX_OUTPUT {
res.Output = res.Output[:constants.MAX_OUTPUT]
}

if runResult.ExecResult.ResultCode != sandbox.RUN_SUCCESS {
res.SetJudgeResultCode(SandboxResultCodeToJudgeResultCode(runResult.ExecResult.ResultCode))
goto Send
Expand Down

0 comments on commit e92dd4d

Please sign in to comment.