Skip to content

Commit

Permalink
feat(lmeval): Disable remote code execution
Browse files Browse the repository at this point in the history
  • Loading branch information
ruivieira committed Nov 26, 2024
1 parent 769fa0b commit 1398925
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
13 changes: 13 additions & 0 deletions controllers/lmes/lmevaljob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,19 @@ func CreatePod(svcOpts *serviceOptions, job *lmesv1alpha1.LMEvalJob, log logr.Lo
volumes = append(volumes, outputPVC)
}

// Disable remote code execution by default
remoteCodeEnvVars := []corev1.EnvVar{
{
Name: "TRUST_REMOTE_CODE",
Value: "0",
},
{
Name: "HF_DATASETS_TRUST_REMOTE_CODE",
Value: "0",
},
}
envVars = append(envVars, remoteCodeEnvVars...)

// Enforce offline mode by default
offlineHuggingFaceEnvVars := []corev1.EnvVar{
{
Expand Down
72 changes: 72 additions & 0 deletions controllers/lmes/lmevaljob_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ func Test_SimplePod(t *testing.T) {
},
},
Env: []corev1.EnvVar{
{
Name: "TRUST_REMOTE_CODE",
Value: "0",
},
{
Name: "HF_DATASETS_TRUST_REMOTE_CODE",
Value: "0",
},
{
Name: "HF_DATASETS_OFFLINE",
Value: "1",
Expand Down Expand Up @@ -313,6 +321,14 @@ func Test_WithCustomPod(t *testing.T) {
},
},
Env: []corev1.EnvVar{
{
Name: "TRUST_REMOTE_CODE",
Value: "0",
},
{
Name: "HF_DATASETS_TRUST_REMOTE_CODE",
Value: "0",
},
{
Name: "HF_DATASETS_OFFLINE",
Value: "1",
Expand Down Expand Up @@ -491,6 +507,14 @@ func Test_EnvSecretsPod(t *testing.T) {
},
},
},
{
Name: "TRUST_REMOTE_CODE",
Value: "0",
},
{
Name: "HF_DATASETS_TRUST_REMOTE_CODE",
Value: "0",
},
{
Name: "HF_DATASETS_OFFLINE",
Value: "1",
Expand Down Expand Up @@ -633,6 +657,14 @@ func Test_FileSecretsPod(t *testing.T) {
Args: generateArgs(svcOpts, job, log),
SecurityContext: defaultSecurityContext,
Env: []corev1.EnvVar{
{
Name: "TRUST_REMOTE_CODE",
Value: "0",
},
{
Name: "HF_DATASETS_TRUST_REMOTE_CODE",
Value: "0",
},
{
Name: "HF_DATASETS_OFFLINE",
Value: "1",
Expand Down Expand Up @@ -1074,6 +1106,14 @@ func Test_ManagedPVC(t *testing.T) {
Args: generateArgs(svcOpts, job, log),
SecurityContext: defaultSecurityContext,
Env: []corev1.EnvVar{
{
Name: "TRUST_REMOTE_CODE",
Value: "0",
},
{
Name: "HF_DATASETS_TRUST_REMOTE_CODE",
Value: "0",
},
{
Name: "HF_DATASETS_OFFLINE",
Value: "1",
Expand Down Expand Up @@ -1205,6 +1245,14 @@ func Test_ExistingPVC(t *testing.T) {
Args: generateArgs(svcOpts, job, log),
SecurityContext: defaultSecurityContext,
Env: []corev1.EnvVar{
{
Name: "TRUST_REMOTE_CODE",
Value: "0",
},
{
Name: "HF_DATASETS_TRUST_REMOTE_CODE",
Value: "0",
},
{
Name: "HF_DATASETS_OFFLINE",
Value: "1",
Expand Down Expand Up @@ -1353,6 +1401,14 @@ func Test_PVCPreference(t *testing.T) {
},
},
Env: []corev1.EnvVar{
{
Name: "TRUST_REMOTE_CODE",
Value: "0",
},
{
Name: "HF_DATASETS_TRUST_REMOTE_CODE",
Value: "0",
},
{
Name: "HF_DATASETS_OFFLINE",
Value: "1",
Expand Down Expand Up @@ -1532,6 +1588,14 @@ func Test_OfflineMode(t *testing.T) {
},
},
Env: []corev1.EnvVar{
{
Name: "TRUST_REMOTE_CODE",
Value: "0",
},
{
Name: "HF_DATASETS_TRUST_REMOTE_CODE",
Value: "0",
},
{
Name: "HF_DATASETS_OFFLINE",
Value: "1",
Expand Down Expand Up @@ -1688,6 +1752,14 @@ func Test_OfflineModeWithOutput(t *testing.T) {
},
},
Env: []corev1.EnvVar{
{
Name: "TRUST_REMOTE_CODE",
Value: "0",
},
{
Name: "HF_DATASETS_TRUST_REMOTE_CODE",
Value: "0",
},
{
Name: "HF_DATASETS_OFFLINE",
Value: "1",
Expand Down

0 comments on commit 1398925

Please sign in to comment.