ComplianceAsCode / ComplianceAsCode/content
Please explain how to write a newline in a banner such as /etc/issue
- Dominant language
- Shell
- Stars
- 2.8k
- Forks
- 828
- Avg merge
- 3d 8m
- Merged PRs (30d)
- 80
Description
#### Description of problem:
This is related to `xccdf_org.ssgproject.content_value_login_banner_text`.
Due to folding and formatting, **spaces** have to be specified in the banner as `[\s\n]+` and this is totally understandable.
However it's unclear how to specify **newline**: `\n` doesn't work in particular.
There is a Jinja macro (`shared/macros/10-bash.jinja`) which replaces the escaped newline into a newline which uses a *sed* line:
~~~
{{# Strips newline or newline escape sequence regex #}}
{{% macro bash_deregexify_banner_newline(banner_var_name, newline) -%}}
{{{ banner_var_name }}}=$(echo "${{{ banner_var_name }}}" | sed 's/(?:\[\\n\]+|(?:\\\\n)+)/{{{ newline }}}/g')
{{%- endmacro %}}
~~~
The above *sed* line doesn't work at all for multiple reasons, checking the GNU *sed* [manual](https://www.gnu.org/software/sed/manual/html_node/Regular-Expressions.html):
- `?:` operator is not a valid operator
- the pipe used to *or* the pattern should be escaped (`\|`)
IMHO the following *sed* may be used instead: `s/\\n\|\[\\n\]/\n/g`
This would match using `\n` or `[\n]`.
Could you please explain what is expected from the user here?
#### SCAP Security Guide Version:
Latest Upstream
#### Operating System Version:
N/A
Contributor guide
Assessment
This issue has not been assessed yet.