-
-
Notifications
You must be signed in to change notification settings - Fork 19.5k
check-meta: warn about misinterpreted *Array variables #335110
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: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,6 +106,16 @@ let | |
|
|
||
| isMarkedInsecure = attrs: (attrs.meta.knownVulnerabilities or []) != []; | ||
|
|
||
| unstructuredArrays = attrs: | ||
| let | ||
| arrayVariables = | ||
| builtins.filter | ||
| (name: builtins.match "^.*Array$" name != null) | ||
| (builtins.attrNames attrs); | ||
| __structuredAttrs = attrs.__structuredAttrs or config.structuredAttrsByDefault; | ||
| in | ||
| if __structuredAttrs then [] else arrayVariables; | ||
|
|
||
| # Alow granular checks to allow only some unfree packages | ||
| # Example: | ||
| # {pkgs, ...}: | ||
|
|
@@ -171,6 +181,7 @@ let | |
| broken-outputs = remediateOutputsToInstall; | ||
| unknown-meta = x: ""; | ||
| maintainerless = x: ""; | ||
| unstructured-arrays = x: ""; | ||
| }; | ||
| remediation_env_var = allow_attr: { | ||
| Unfree = "NIXPKGS_ALLOW_UNFREE"; | ||
|
|
@@ -439,6 +450,18 @@ let | |
| # Please also update the type in /pkgs/top-level/config.nix alongside this. | ||
| else if hasNoMaintainers attrs then | ||
| { valid = "warn"; reason = "maintainerless"; errormsg = "has no maintainers"; } | ||
| else if unstructuredArrays attrs != [] then | ||
| let | ||
| quote = s: ''"${s}"''; | ||
| variables = unstructuredArrays attrs; | ||
| variablesStr = builtins.concatStringsSep ", " (map quote variables); | ||
| usePlural = variables != [(builtins.head variables)]; | ||
| plural = optionalString usePlural "s"; | ||
| in | ||
| { valid = "warn"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @wolfgangwalther that this ought to be an error, but the set of packages it touches is pretty high. We'll patch it all up in the next staging-next.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to consider out‐of‐tree users too. I agree with the suggestion to add the “this will break” warning and then make it a hard error on the next release. |
||
| reason = "unstructured-arrays"; | ||
| errormsg = "The variable${plural} ${variablesStr} will be misinterpreted as single element bash array${plural} because __structuredAttrs is not set"; | ||
| } | ||
| # ----- | ||
| else validYes; | ||
|
|
||
|
|
||
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.
This is pretty cute.
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.
Is there a reason we’re spelling
lib.length variables != 1like that…?