Skip to content
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

Specify VCL path and load multiple files at once with vcl.load in cli #3906

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

walid-git
Copy link
Member

@walid-git walid-git commented Mar 14, 2023

This PR adds two features to vcl.load cli command:

  • A "-p <vcl_path>" argument that is prepended to VLC_PATH parameter when loading the vcl.
  • Specify multiple vcl files with a single vcl.load command.

In order to have a way to accept multiple files, we need to be able to accept any number of arguments (>2), but with the current implementation there will be a confusion for the last argument as there is no way to tell if it is a state (auto|cold|warm) or a VCL file. To address that, the first commit turns the state argument into an optional [-s auto|cold|warm] argument, and the second one does the same for vcl.inline for compliance.

The new format for vcl.load command is the following:
vcl.load [-s auto|cold|warm] [-p vcl_path] <configname> <file1> [file2, ...]

@nigoroll
Copy link
Member

quick bugwash notes:

  • generally in favor
  • let's not break vcl.load
  • but rather add vcl.load_files [-s state] [-p path] <file> ...
  • -p should be forbidden if vcl_path is protected

please do also add some more detailed documentation and changes.rst entry

@walid-git walid-git force-pushed the vcl_path_534 branch 8 times, most recently from 53023a4 to e160358 Compare March 27, 2023 09:00
@dridi
Copy link
Member

dridi commented Mar 28, 2023

Note: the pull request is currently failing deprecated persistent storage test cases in circleci, but with 53023a4 that has the feature jammed into vcl.load instead of a new vcl.load_files command tests are passing again.

We need to find what is causing this, but we weren't able to reproduce it locally.

@walid-git walid-git force-pushed the vcl_path_534 branch 8 times, most recently from 7c91254 to 58b0391 Compare April 13, 2023 08:09
@walid-git
Copy link
Member Author

Thanks to @bsdphk 's commit 22f5e216fb22ef4ae17b877ed80a99dc090123ed, all the tests are now passing successfully. Reviews are welcome.

This commit introduces a new vcl.load_files cli command, which is similar to vcl.load
except that it turns the state argument into an optional [-s auto|cold|warm] argument,
and adds the ability to specify multiple vcl files at once:

vcl.load_files [-s auto|cold|warm] <configname> <file1> [file2, ...]

The specified files are parsed in the order they were provided and treated
as if they were concatenated and merged into a single vcl file
@dridi
Copy link
Member

dridi commented May 15, 2023

Bugwash: this triggered a CLI privilege discussion in need for an overview.

This commit adds an optional -p argument to vcl.load_files cli command to
allow the user to specify a path that will be prepended to the VCL_PATH
parameter when loading the vcl files
@walid-git
Copy link
Member Author

Updated the doc to mention that -p fails when vcl_path is read only

@nigoroll
Copy link
Member

bugwash: @bsdphk wants to finish a review of the CLI privilege design before making a decision on this ticket.

@dridi
Copy link
Member

dridi commented Jun 14, 2023

I found myself giving @walid-git to read what I still consider to date the best random outburst (ever since I first read it).

https://varnish-cache.org/docs/trunk/phk/barriers.html

Seeing the diagram, I noticed the ADMIN vs OPER distinction @bsdphk was making on IRC when we last discussed this. My claim was that this distinction was a bit too stringent, especially since our defaults require root privileges to read the CLI secret.

According to the diagram, the CLI actually is an admin privilege and the "mere" operator only has VSM access (and even that requires specific credentials with our defaults).

So overriding the vcl_path on a per-VCL basis can be done on the CLI, since CLI privileges are the same as varnishd -r privileges. I see no actual concern in this area, and I finally remember from where I got my interpretation of our security model.

Comment on lines +637 to +641
if (pp->flags & PROTECTED) {
VCLI_SetResult(cli, CLIS_AUTH);
VCLI_Out(cli, "parameter \"vcl_path\" is protected.\n");
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify my previous comment, since both varnishd -r and vcl.load_files require admin privileges as per our security model, I would be fine relaxing this rule and allowing both a read-only global vcl_path and per-VCL additional path since they take precedence.

@bsdphk
Copy link
Contributor

bsdphk commented Jun 26, 2023

This is on hold until we have agreed if the 2010 vintage security barriers are still the right one for us.

Input solicited, in particular on different "levels" of CLI access and how to determine which one to offer on a given connection.

@dridi
Copy link
Member

dridi commented Jul 10, 2023

bugwash: Varnish Software will collect security barriers requirements and submit them for discussion.

Note to self: #3729 should serve as input too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants