-
Notifications
You must be signed in to change notification settings - Fork 46
fix: Prevent lm-eval command escape #503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Reviewer's GuideThis PR refactors command construction to eliminate shell invocation, integrates comprehensive input validation in the controller and CRD schemas to block unsafe patterns, and updates tests to reflect these changes. Sequence diagram for LMEvalJob input validation in controllersequenceDiagram
participant Controller
participant Validation
participant StatusUpdate
Controller->>Validation: ValidateUserInput(job)
alt Validation fails
Validation-->>Controller: error
Controller->>StatusUpdate: Update job.Status (State=Complete, Reason=Failed, Message)
Controller-->>Controller: Log error
Controller-->>Controller: Return error
else Validation passes
Validation-->>Controller: nil
Controller->>Controller: Continue with job processing
end
Class diagram for new validation logic and patternsclassDiagram
class LMEvalJob {
+LMEvalJobSpec Spec
+LMEvalJobStatus Status
}
class LMEvalJobSpec {
+string Model
+[]Arg ModelArgs
+TaskList TaskList
+string Limit
+[]Arg GenArgs
+*OfflineSpec Offline
+*int BatchSize
+string SystemInstruction
+*ChatTemplate ChatTemplate
}
class TaskList {
+[]string TaskNames
+[]TaskRecipe TaskRecipes
+*CustomArtifacts CustomArtifacts
+*CustomTasks CustomTasks
}
class Validation {
+ValidateUserInput(job)
+ValidateModelName(model)
+ValidateArgs(args, argType)
+ValidateTaskNames(taskNames)
+ValidateTaskRecipes(args, argType)
+ValidateCustomArtifactValue(input)
+ValidateLimit(limit)
+ValidateS3Path(path)
+ValidateBatchSizeInput(batchSize)
+ValidateSystemInstruction(instruction)
+ValidateChatTemplateName(name)
+ValidateGitURL(url)
+ValidateGitPath(path)
+ValidateGitBranch(branch)
+ValidateGitCommit(commit)
+ContainsShellMetacharacters(input)
}
class Patterns {
+PatternModelName
+PatternTemplateName
+PatternArgName
+PatternArgValue
+PatternLimit
+PatternTaskName
+AllowedModels
}
LMEvalJobSpec o-- TaskList
TaskList o-- CustomArtifacts
TaskList o-- CustomTasks
LMEvalJob o-- LMEvalJobSpec
LMEvalJob o-- LMEvalJobStatus
Validation ..> Patterns : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ruivieira - I've reviewed your changes - here's some feedback:
- The PR mixes shell‐escaping fixes and extensive input validation/CRD changes — consider splitting it into smaller, focused PRs (one for command generation and one for validation/schema updates) for easier review and maintainability.
- The validation logic and kubebuilder regex tags are duplicated across patterns.go, validation.go and the CRD YAML — consider centralizing these patterns to avoid drift and ensure consistency.
- Injecting ValidateUserInput in the controller is helpful, but it might be cleaner to move input validation into a webhook (or a dedicated admission step) so invalid CRs are rejected before reconciliation.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The PR mixes shell‐escaping fixes and extensive input validation/CRD changes — consider splitting it into smaller, focused PRs (one for command generation and one for validation/schema updates) for easier review and maintainability.
- The validation logic and kubebuilder regex tags are duplicated across patterns.go, validation.go and the CRD YAML — consider centralizing these patterns to avoid drift and ensure consistency.
- Injecting ValidateUserInput in the controller is helpful, but it might be cleaner to move input validation into a webhook (or a dedicated admission step) so invalid CRs are rejected before reconciliation.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
PR image build and manifest generation completed successfully! 📦 PR image: 📦 LMES driver image: 📦 LMES job image: 📦 Guardrails orchestrator image: 🗂️ CI manifests |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: christinaexyou The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
New changes are detected. LGTM label has been removed. |
|
@ruivieira: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Summary by Sourcery
Implement strict input validation and secure command generation for LMEvalJob: introduce ValidateUserInput, integrate it into the reconciler to reject malicious CRs, harden CRD schema with patterns/enums, refactor CLI construction to use argument slices, and expand test coverage accordingly.
New Features:
Bug Fixes:
sh -ecand sanitizing all CLI inputsEnhancements:
Tests: