about summary refs log tree commit diff
path: root/tvix/derivation/src
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-01-17T11·42+0100
committerflokli <flokli@flokli.de>2023-01-18T17·13+0000
commitb1e8fe7212618a61b78eeefa65075295fe2e40b2 (patch)
tree451ded5c12abca1f9c7ebbd2f86ae98c3b2b4496 /tvix/derivation/src
parent4a256dda094b806198b316be7460a0423f683a51 (diff)
feat(tvix/derivation): check for other invalid output names r/5699
This uses the exposed StorePath::validate_name method to check for other
invalid output names (for which it would not be possible to construct a
store path of).

Change-Id: Ia3f65e19a07ef164f9f64013a5f37cbac99eb8e0
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7855
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/derivation/src')
-rw-r--r--tvix/derivation/src/validate.rs17
1 files changed, 11 insertions, 6 deletions
diff --git a/tvix/derivation/src/validate.rs b/tvix/derivation/src/validate.rs
index a2143509011b..c6cd2f8b9e3e 100644
--- a/tvix/derivation/src/validate.rs
+++ b/tvix/derivation/src/validate.rs
@@ -20,8 +20,11 @@ impl Derivation {
             // meaning.
             //
             // Other output names that don't match the name restrictions from
-            // [StorePath] will fail output path calculation.
-            if output_name.is_empty() || output_name == "drv" {
+            // [StorePath] will fail the [StorePath::validate_name] check.
+            if output_name.is_empty()
+                || output_name == "drv"
+                || StorePath::validate_name(&output_name).is_err()
+            {
                 return Err(DerivationError::InvalidOutputName(output_name.to_string()));
             }
 
@@ -73,10 +76,12 @@ impl Derivation {
                 // `drvPath` key (which already exists) and has a different
                 // meaning.
                 //
-                // Other output names that don't match the name restrictions
-                // from [StorePath] can't be constructed with this library, but
-                // are not explicitly checked here (yet).
-                if output_name.is_empty() || output_name == "drv" {
+                // Other output names that don't match the name restrictions from
+                // [StorePath] will fail the [StorePath::validate_name] check.
+                if output_name.is_empty()
+                    || output_name == "drv"
+                    || StorePath::validate_name(&output_name).is_err()
+                {
                     return Err(DerivationError::InvalidInputDerivationOutputName(
                         input_derivation_path.to_string(),
                         output_name.to_string(),