@@ -742,17 +742,105 @@ export const GenerationIsolationEvidenceV2Schema = z
742742 }
743743 } ) ;
744744
745+ export const GENERATION_ISOLATION_PROBE_VERSION_V3 =
746+ "counterlab-generation-isolation-v3" as const ;
747+
748+ export const GENERATION_ISOLATION_POLICY_VERSION_V3 =
749+ "counterlab-posix-dac-process-policy-v1" as const ;
750+
751+ const GenerationIsolationProcessIdentitySchema = z . strictObject ( {
752+ brokerUid : z . literal ( 0 ) ,
753+ brokerGid : z . literal ( 0 ) ,
754+ runnerUid : z . literal ( 10_001 ) ,
755+ runnerGid : z . literal ( 10_001 ) ,
756+ generatorUid : z . literal ( 10_002 ) ,
757+ generatorGid : z . literal ( 10_002 ) ,
758+ generatorSupplementaryGroupsCleared : z . literal ( true ) ,
759+ generatorCapabilitiesEmpty : z . literal ( true ) ,
760+ generatorNoNewPrivileges : z . literal ( true ) ,
761+ protectedPathsUnreadable : z . literal ( true ) ,
762+ protectedPathsUnwritable : z . literal ( true ) ,
763+ parentEnvironmentUnreadable : z . literal ( true ) ,
764+ brokerEnvironmentUnreadable : z . literal ( true ) ,
765+ workspaceVisible : z . literal ( true ) ,
766+ workspaceWritable : z . literal ( true ) ,
767+ outsideWorkspaceWritesDenied : z . literal ( true ) ,
768+ fixedKernelUnavailable : z . literal ( true ) ,
769+ credentialReadOnlyDuringInitialization : z . literal ( true ) ,
770+ credentialRevocationSupported : z . literal ( true ) ,
771+ boundedLaunchesEnforced : z . literal ( true ) ,
772+ maximumLaunches : z . literal ( 3 ) ,
773+ } ) ;
774+
775+ export const GenerationIsolationProbePayloadV3Schema = z . strictObject ( {
776+ schemaVersion : z . literal ( "3" ) ,
777+ probeVersion : z . literal ( GENERATION_ISOLATION_PROBE_VERSION_V3 ) ,
778+ service : z . literal ( "counterlab-hosted-runner" ) ,
779+ probe : z . literal ( "non-root-startup" ) ,
780+ checks : z . tuple ( [
781+ z . literal ( "entrypoint" ) ,
782+ z . literal ( "non-root-user" ) ,
783+ z . literal ( "immutable-paths" ) ,
784+ z . literal ( "python" ) ,
785+ z . literal ( "setpriv" ) ,
786+ z . literal ( "privsep-broker" ) ,
787+ z . literal ( "posix-dac-process-identity" ) ,
788+ z . literal ( "writable-roots" ) ,
789+ ] ) ,
790+ generationFilesystemReadIsolation : z . literal ( "OS_ENFORCED" ) ,
791+ mechanism : z . literal ( "posix-dac-process-identity" ) ,
792+ brokerIdentity : z . literal ( "0:0" ) ,
793+ runnerIdentity : z . literal ( "10001:10001" ) ,
794+ generatorIdentity : z . literal ( "10002:10002" ) ,
795+ policyVersion : z . literal ( GENERATION_ISOLATION_POLICY_VERSION_V3 ) ,
796+ processIdentity : GenerationIsolationProcessIdentitySchema ,
797+ } ) ;
798+
799+ export const GenerationIsolationEvidenceV3Schema = z
800+ . strictObject ( {
801+ schemaVersion : z . literal ( "3" ) ,
802+ status : z . literal ( "VERIFIED" ) ,
803+ generationFilesystemReadIsolation : z . literal ( "OS_ENFORCED" ) ,
804+ sourceCommit : GitCommitSchema ,
805+ sourceTreeSha256 : Sha256Schema ,
806+ localImageTag : z . string ( ) . regex ( / ^ c o u n t e r l a b - r u n n e r : g i t - [ a - f 0 - 9 ] { 40 } $ / ) ,
807+ localImageDigest : OciDigestSchema ,
808+ imageUser : z . literal ( "0:0" ) ,
809+ policyVersion : z . literal ( GENERATION_ISOLATION_POLICY_VERSION_V3 ) ,
810+ probePayload : GenerationIsolationProbePayloadV3Schema ,
811+ probePayloadSha256 : Sha256Schema ,
812+ verifiedAt : z . iso . datetime ( { offset : true } ) ,
813+ verifierVersion : z . literal ( "counterlab-generation-isolation-evidence-v3" ) ,
814+ } )
815+ . superRefine ( ( evidence , context ) => {
816+ if (
817+ evidence . localImageTag !==
818+ `counterlab-runner:git-${ evidence . sourceCommit } `
819+ ) {
820+ context . addIssue ( {
821+ code : "custom" ,
822+ path : [ "localImageTag" ] ,
823+ message : "generation-isolation image tag must bind the source commit" ,
824+ } ) ;
825+ }
826+ } ) ;
827+
745828export const GenerationIsolationProbePayloadAnySchema = z . discriminatedUnion (
746829 "schemaVersion" ,
747830 [
748831 GenerationIsolationProbePayloadSchema ,
749832 GenerationIsolationProbePayloadV2Schema ,
833+ GenerationIsolationProbePayloadV3Schema ,
750834 ] ,
751835) ;
752836
753837export const GenerationIsolationEvidenceSchema = z . discriminatedUnion (
754838 "schemaVersion" ,
755- [ GenerationIsolationEvidenceV1Schema , GenerationIsolationEvidenceV2Schema ] ,
839+ [
840+ GenerationIsolationEvidenceV1Schema ,
841+ GenerationIsolationEvidenceV2Schema ,
842+ GenerationIsolationEvidenceV3Schema ,
843+ ] ,
756844) ;
757845
758846export const QualifiedRunnerReleaseV1Schema = z
0 commit comments