Provide a mechanism to disable variables #18
Replies: 6 comments 10 replies
-
This is true, but will be so with any syntax. Using other syntax such as
I think editor support could help on this.
We agree, but this issue is orthogonal to variables. You can have variables without imports and viceversa.
In that case, no harm done, you just have to be aware that your config file needs to be self contained.
This should be the default, yes, for security purposes.
I don't think so. Just don't use variables and it's the same!
I guess Gura could exist without variables, but I feel having to escape
I feel this is unnecessary, applications can escape $ signs when needed. The same goes for any keyword in Gura. |
Beta Was this translation helpful? Give feedback.
-
Did you mean ¿environmental variable in every instance of the variable word
in your op? If not, env variables and imports work similarly and both have
security issues. But they are orthogonal to variables per se. Why disable
all variables if env variables are the issue?
El mié., 22 jun. 2022 12:34, Jay Oster ***@***.***> escribió:
… We agree, but this issue is orthogonal to variables. You can have
variables without imports and viceversa.
Maybe a small misunderstanding, here. For clarity, I linked to the thread
about imports as an example of a similar security issue. In this case, the
issue is with exposing *environment variables*, and is indeed unrelated
to imports.
—
Reply to this email directly, view it on GitHub
<#18 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMA6B2ROGQBUPFTLDJWCBLVQMW77ANCNFSM5ZQR26UA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I agree with both parties: First of all, it is true that it may represent security issues since any file that is parsed server-side would access the global variables exposing them in the parsed result. So it seems good to me to provide in the technical documentation a section indicating that tools implementing Gura serialization should offer the mentioned options:
Secondly, regarding the default option, wouldn't option 2 (only local variables enabled) be better? Since that does not represent a security problem, it only generates an inconvenience in the case of having to define several times some string with the |
Beta Was this translation helpful? Give feedback.
-
¿Why disable variables? Defined in the same file, they are self-contained.
W By adding API ability to disable variables, you are effectively making
many Gura config files invalid. Worse, the error will possibly be parsed as
a correct string!
e've already discussed additional templating mechanisms and decided Gura
will not include those. It will stand in the middle between a simple config
file and a complex templating system.
@jay, one of your original concerns is about having to escape $. As Genaro
mentioned, you can quote those, or as you said, you can escape them in your
string before saving to a Gura file. This is not something unheard of, and
you will also have to escape other characters such as "], etc.
The other one is about safety with env variables. This is 100% correct.
But disabling variables altogether is both unnecessary and dangerous.
…On Thu, Jun 23, 2022 at 10:48 AM Genaro Camele ***@***.***> wrote:
There are several interesting points in your response. But I don't see the
consideration of Literal Strings (no multi-lines, just single quotes ',
read the String section <https://gura.netlify.app/docs/spec#string> for
more). Your example could look like this:
company: 'Acme tools'ledger: [
date: '2022-06-22'
description: 'Cash'
debit: '$613.00'
credit: '$0.00',
date: '2022-06-22'
description: 'Sales'
debit: '$0.00'
credit: '$803.53',
date: '2022-06-22'
description: 'Sales Tax Payable'
debit: '$0.00'
credit: '$200.88',]
So no need to resort to multi-line literal strings or escaped basic
strings for your requirement :D.
With this in mind, I still think it's a good idea to have a mechanism to
disable variable consideration to prevent all the problems you mentioned.
But as far as readability is concerned there are the following solutions:
- Use Literal Strings (although perhaps basic strings and literal
strings will be mixed).
- Disable the use of variables in your tool so that, in case the
configuration is defined by a user, he/she cannot insert a variable by
accident.
- Set up the pre-processor you are talking about, but it seems to me
unnecessary work since you have the two options above.
The use of variables was born from some annoyances I had when I had to
define services in Docker. For example:
version: '3'
$user: 'test'$pass: 'test'$db: 'test'
services:
# PostgreSQL
db:
image: postgres:13
environment:
POSTGRES_USER: $user
POSTGRES_PASSWORD: $pass
POSTGRES_DB: $db
# Some service that needs to connect to PostgreSQL
other_service:
image: my_img
environment:
POSTGRES_USER: $user
POSTGRES_PASSWORD: $pass
POSTGRES_DB: $db
Now, scale the example to 5 interconnected services! The use of variables
helps in this kind of problem. Of course, if security is compromised, the
implementation must offer the mechanism to disable variables.
—
Reply to this email directly, view it on GitHub
<#18 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMA6B3RZF2CYTRWCLO2U5TVQRTJ7ANCNFSM5ZQR26UA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
On Thu, Jun 23, 2022 at 11:59 AM Genaro Camele ***@***.***> wrote:
Yep, the incompatibility issue with the same Gura file sounds bad... So
@facundoq <https://github.com/facundoq>, you propose only allowing to
disable ENV vars in parsers? And the rest of the implementation specs would
remain the same, wouldn't it?
Exactly. As Jay says, it would be safer to disable it by default so that
variables are not read inadvertently.
… Message ID: ***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
I think it's important to point out that you will ALWAYS need to escape
something. $ and ' are some of the cases, but not the only ones. Perhaps an
API function to safely do this that will automatically update with new
versions would come in handy. But there's no going around the fact that the
file itself will show the escaped characters.
El jue., 23 jun. 2022 14:30, Jay Oster ***@***.***> escribió:
… I didn’t consider single-line literal strings because they do not allow
using the single quote character ' at all. It is commonly used in English
contractions, so it is expected to appear in strings.
The use of variables was born from some annoyances I had when I had to
define services in Docker.
Yeah, I have done enough service configuration to be familiar with the
problem and how variables address it. It happens everywhere. Helm, Ansible,
Chef, …
—
Reply to this email directly, view it on GitHub
<#18 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMA6BZ5Y6VCZPALTIYFWW3VQSNNDANCNFSM5ZQR26UA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Motivation
Variable interpolation can be useful in some contexts, but causes issues in others. One example where variables are unwanted is using Gura as a simple flat file database. Gura is a good alternative to CSV, JSON, YAML, and some other options in this use case. The existence of variables causes some problems, however.
$
literal awkward. A ledger example highlights this shortcoming:It is easy to forget about (or be unaware of) escaping the
$
character. The parser raisesVariableNotDefinedError
in this situation.Automatically pulling information from the environment may be a privacy or security violation in sensitive environments. Some examples include a website that accepts Gura file uploads and parses them on the backend for validation, or a native application that uses Gura for its embedded database and users decide to update the database from untrusted sources. (See also Provide a mechanism to disable imports #13.)
Some platforms may not provide access to environment variables at all, such as WASM VMs and web browsers.
Proposal
Each implementation must provide a mechanism to disable variable interpolation with environment variables, and also to disable variable interpolation altogether. The configuration option has three states:
The first state acts as Gura does today. The second state acts as it does today with the exception that the environment is never accessed; all variables must be defined in the Gura tree.
The third state treats all
$
characters as literals, and all escaped\$
as the same literal$
character. In other words, existing Gura files continue to parse correctly, except variables are no longer interpolated. This state also allows unescaped$
literals so that strings like"$613.00"
become valid. These files will not parse when variables are enabled. The parser raisesVariableNotDefinedError
in this situation.Example in Python:
Considerations
$
characters to be treated as literals will bifurcate the Gura ecosystem into applications that support these files and applications which do not. Is this an acceptable tradeoff? Is there a better alternative?Version
Gura 2.0.0
because it contains many other breaking changes, including the aforementioned #13.Changes
Beta Was this translation helpful? Give feedback.
All reactions