Symfony framework.yaml invalid YAML - but it's not? - symfony

I've started getting this error...not sure why or how?
Here is the framework.yaml:
security:
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
providers:
ad_ldap:
ldap:
service: Symfony\Component\Ldap\Ldap
base_dn: dc=mydomain,dc=local
search_dn: 'appuser'
search_password: "xxx"
default_roles: ROLE_USER
uid_key: 'sAMAccountName'
filter: '({uid_key}={username})'
Giving me this error:
In FileLoader.php line 180:
The file "/vagrant/project/config/packages/security.yaml" does not
contain valid YAML: Unexpected characters near "rname})' " at
line 12 (near "filter: '({uid_key}={us ername})' ") in
/vagrant/project/config/packages/security.yaml (which is loaded in
resource "/vagrant/project/config/packages/security.yaml").
In YamlFileLoader.php line 693:
The file "/vagrant/project/config/packages/security.yaml" does not
contain valid YAML: Unexpected characters near "rname})' " at
line 12 (near "filter: '({uid_key}={us ername})' ").
In Parser.php line 760:
Unexpected characters near "rname})' " at line 12 (near
"filter: '({uid_key}={username})' ").

The problem is a vendor issue with symfony and is corrected already but not released as of this writing.
https://github.com/symfony/symfony/issues/39229

See: https://symfony.com/doc/current/components/yaml/yaml_format.html#strings
the part:
Strings containing any of the following characters must be quoted. Although you can use double quotes, for these characters it is more convenient to use single quotes, which avoids having to escape any backslash :
:, {, }, [, ], ,, &, *, #, ?, |, -, <, >, =, !, %, #, `
Can you try quoting all strings there? (using single quotes)
Also, which Symfony version?

Related

JQ error Cannot index string with number with scan

I have error with scan function, why?
https://jqplay.org/s/E-0qbbzRPS
I need do this without -r
There are two issues with your filter. Firstly, you need to separate parameters to a function with semicolon ;, not comma ,:
scan("([0-9A-Za-z_]+) == '([0-9A-Za-z_]+)"; "g")
Secondly, scan with two parameters is not implemented (in contradiction to the manual).
jq: error: scan/2 is not defined at <top-level>, line 1:
But as you are using scan, your regex will match multiple occurrences anyway, so you may as well just drop it :
.spec.selector | [scan("([0-9A-Za-z_]+) == '([0-9A-Za-z_]+)") | {(.[0]): .[1]}]
[
{
"app": "nginx"
}
]
Demo

Change ossec(wazuh) agent profiles via saltstack

I'm trying to modify the <config-profile> section of a ossc.conf file, including a grains content.
something like:
ossec-profiles:
- profile1
- profile2
and I want to modify the section <config-profile> from
<config-profile>centos, centos7</config-profile>
to
<config-profile>centos, centos7, profile1, profile2</config-profile>
in the ossec.conf file
Any idea?
This can be done by using file.replace module which makes you able to change a text in a file based on a pattern. So in your case you can do the following:
You need to select the pattern as regex group so you can use it later as shown below
configure_ossec:
file.replace:
- name: /path/to/ossec.conf
- pattern: '((<config-profile>.*?)[^<]*)'
- repl: {{ '\\1, ' + pillar['ossec-profiles'] | join(', ') }}
Or you might use this pattern to match only whatever inside config-profile tags then you will be able to call it again in the repl parameter:
(?<=<config-profile>)(.*)(?=<\/config-profile>)
Note: As pillar['ossec-profiles'] should return a list of profiles
then you have to use the join filter in order to separate the values
with comma as a delimiter
And finally the output expected to be something like this:
Changes:
----------
diff:
---
+++
## -1 +1 ##
-<config-profile>centos, centos7</config-profile>
+<config-profile>centos, centos7, profile1, profile2</config-profile>

saltstack pattern match failing

I am trying to replace a line in httpd.conf in packer using masterless salt. I always check the pattern using grep command and if it works then the same will work in saltstack too but this time it fails. As I am not good in regular expression please help on this.
I want to replace the below line
CustomLog "|'/apps/CA/secure-proxy/bizportalsps/httpd/bin/rotatelogs' '/apps/CA/secure-proxy/bizportalsps/httpd/logs/access_log' 10M" common
with
CustomLog /apps/CA/secure-proxy/bizportalsps/httpd/logs/access_log common
So I used
Log-file-update:
file.replace:
- name: /apps/CA/secure-proxy/bizportalsps/httpd/conf/httpd.conf
- pattern: 'CustomLog \"\|'/apps/CA/secure-proxy/bizportalsps/httpd/bin/rotatelogs' '/apps/CA/secure-proxy/bizportalsps/httpd/logs/access_log' 10M\" common'
- repl: 'CustomLog /apps/CA/secure-proxy/bizportalsps/httpd/logs/access_log common'
- append_if_not_found: False
But its failing. Any suggestions will be very helpful.
The below is the error.
<pre> <code>
amazon-ebs: [CRITICAL] Rendering SLS 'base:install' failed: while parsing a block mapping
amazon-ebs: in "<unicode string>", line 46, column 7:
amazon-ebs: - pattern: 'CustomLog \"\|'/apps/C ...
amazon-ebs: ^
amazon-ebs: expected <block end>, but found '<scalar>'
amazon-ebs: in "<unicode string>", line 46, column 32:
amazon-ebs: - pattern: 'CustomLog \"\|'/apps/CA/secure-proxy/bizportals ...
amazon-ebs: ^
This is because of the first ' in your pattern.
This should work,
Log-file-update:
file.replace:
- name: /etc/pki/tls/certs/test
- pattern: CustomLog \"|\'/apps/CA/secure-proxy/bizportalsps/httpd/bin/rotatelogs\' \'/apps/CA/secure-proxy/bizportalsps/httpd/logs/access_log\' 10M\" common
- repl: CustomLog /apps/CA/secure-proxy/bizportalsps/httpd/logs/access_log common
- append_if_not_found: False

How to Escape "%" in parameters.yml symfony2

I would like escape a character % in file : parameters.yml, because my password begin by %
database_driver3: pdo_sqlsrv
database_host3: 192.168.10.10
database_port3: 1455
database_name3: MyDB
database_user3: sa
database_password3: %ABC$Admin_2012%
What I really should be doing ?
The easiest way is to simply add quotes to the values you want to escape
database_password3: "%ABC$Admin_2012%"
OR by using double % credit - skowron-line
database_password3: %%ABC$Admin_2012%%

Why my Reg Exp in ga:filters is changed in the final request?

I am working on a GA-API stuff and I found the tool:
http://ga-dev-tools.appspot.com/explorer/
very useful.
But when I copy the Reg Exp into my own code as follows:
function queryCoreReportingApi(profileId) {
gapi.client.analytics.data.ga.get({
'ids': 'ga:' + profileId,
'start-date': lastNDays(30),
'end-date': lastNDays(0),
'metrics': 'ga:visitors',
'dimensions': 'ga:pagePath',
'sort': '-ga:visitors',
'filters': 'ga:pagePath=~/q-\d+/.+',
'max-results': 50
}).execute(handleCoreReportingResults);
}
I can't get any result.
I found that
filters: "ga:pagePath=~/q-\d+/.+",
is changed to
filters: "ga:pagePath=~/q-d+/.+"
The \d becomes d and I failed to get what I want.
Why the \ is just gone? Any tips?
Thanks!
Aw, looking at the filter reference, I would suggest escaping the backslash. So technically, you would end up with double backslashes:
"ga:pagePath=~/q-\\d+/.+",
See the linked page, section Filter Expressions:
Reserved characters — The semicolon, comma, and backslash must all be
backslash escaped when they appear in an expression.
Hope this helps.

Resources