@Test public void testValidEntryPoint() { JobDescriptor<?> jobDescriptor = newBatchJob() .map(jd -> jd.but(d -> d.getContainer().toBuilder() .withEntryPoint(asList("/bin/sh", "-c", "sleep 10")))) .getValue(); ExtendedJobSanitizer sanitizer = new ExtendedJobSanitizer(configuration, jobAssertions, entitySanitizer, disruptionBudgetSanitizer, jd -> false, jd -> false, titusRuntime); Optional<JobDescriptor<?>> sanitized = sanitizer.sanitize(jobDescriptor); assertThat(sanitized).isNotPresent(); }
@Override public <T> Optional<T> sanitize(T entity) { T sanitized = entitySanitizer.sanitize(entity).orElse(entity); if (sanitized instanceof com.netflix.titus.api.jobmanager.model.job.JobDescriptor) { sanitized = (T) sanitizeJobDescriptor((JobDescriptor) sanitized); } return entity == sanitized ? Optional.empty() : Optional.of(sanitized); }
ExtendedJobSanitizer implements EntitySanitizer { @Override public <T> Optional<T> sanitize(T entity) { T sanitized = entitySanitizer.sanitize(entity).orElse(entity); if (sanitized instanceof com.netflix.titus.api.jobmanager.model.job.JobDescriptor) { sanitized = (T) sanitizeJobDescriptor((JobDescriptor) sanitized); } return entity == sanitized ? Optional.empty() : Optional.of(sanitized); } }
ExtendedJobSanitizer implements EntitySanitizer { @Override public <T> Optional<T> sanitize(T entity) { T sanitized = entitySanitizer.sanitize(entity).orElse(entity); if (sanitized instanceof com.netflix.titus.api.jobmanager.model.job.JobDescriptor) { sanitized = (T) sanitizeJobDescriptor((JobDescriptor) sanitized); } return entity == sanitized ? Optional.empty() : Optional.of(sanitized); } ExtendedJobSanitizer(JobManagerConfiguration jobManagerConfiguration,
                                JobAssertions jobAssertions,
                                @Named(JOB_STRICT_SANITIZER) EntitySanitizer entitySanitizer,
                                DisruptionBudgetSanitizer disruptionBudgetSanitizer,
                                @Named(SECURITY_GROUPS_REQUIRED_FEATURE) Predicate<JobDescriptor> securityGroupsRequiredPredicate,
                                @Named(ENVIRONMENT_VARIABLE_NAMES_STRICT_VALIDATION_FEATURE) Predicate<JobDescriptor> environmentVariableNamesStrictValidationPredicate,
                                TitusRuntime titusRuntime); }
ExtendedJobSanitizer implements EntitySanitizer { @Override public <T> Optional<T> sanitize(T entity) { T sanitized = entitySanitizer.sanitize(entity).orElse(entity); if (sanitized instanceof com.netflix.titus.api.jobmanager.model.job.JobDescriptor) { sanitized = (T) sanitizeJobDescriptor((JobDescriptor) sanitized); } return entity == sanitized ? Optional.empty() : Optional.of(sanitized); } ExtendedJobSanitizer(JobManagerConfiguration jobManagerConfiguration,
                                JobAssertions jobAssertions,
                                @Named(JOB_STRICT_SANITIZER) EntitySanitizer entitySanitizer,
                                DisruptionBudgetSanitizer disruptionBudgetSanitizer,
                                @Named(SECURITY_GROUPS_REQUIRED_FEATURE) Predicate<JobDescriptor> securityGroupsRequiredPredicate,
                                @Named(ENVIRONMENT_VARIABLE_NAMES_STRICT_VALIDATION_FEATURE) Predicate<JobDescriptor> environmentVariableNamesStrictValidationPredicate,
                                TitusRuntime titusRuntime); @Override Set<ValidationError> validate(T entity); @Override Optional<T> sanitize(T entity); }
ExtendedJobSanitizer implements EntitySanitizer { @Override public <T> Optional<T> sanitize(T entity) { T sanitized = entitySanitizer.sanitize(entity).orElse(entity); if (sanitized instanceof com.netflix.titus.api.jobmanager.model.job.JobDescriptor) { sanitized = (T) sanitizeJobDescriptor((JobDescriptor) sanitized); } return entity == sanitized ? Optional.empty() : Optional.of(sanitized); } ExtendedJobSanitizer(JobManagerConfiguration jobManagerConfiguration,
                                JobAssertions jobAssertions,
                                @Named(JOB_STRICT_SANITIZER) EntitySanitizer entitySanitizer,
                                DisruptionBudgetSanitizer disruptionBudgetSanitizer,
                                @Named(SECURITY_GROUPS_REQUIRED_FEATURE) Predicate<JobDescriptor> securityGroupsRequiredPredicate,
                                @Named(ENVIRONMENT_VARIABLE_NAMES_STRICT_VALIDATION_FEATURE) Predicate<JobDescriptor> environmentVariableNamesStrictValidationPredicate,
                                TitusRuntime titusRuntime); @Override Set<ValidationError> validate(T entity); @Override Optional<T> sanitize(T entity);  }