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

Run tmux only right after sshd/login #4885

Merged
merged 1 commit into from
Oct 3, 2019

Conversation

comps
Copy link
Collaborator

@comps comps commented Oct 2, 2019

This prevents tmux-inside-tmux for common use cases like su -.

I'm not quite sure how the OVAL should look like or whether the tail -5 is valid, hence I'm submitting this as a draft. Any opinions?

Thanks.

Copy link
Member

@yuumasato yuumasato left a comment

Choose a reason for hiding this comment

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

In this line, a regular expression like this could work. I haven't tested though.

if [ "$PS1" ]; then\n[\s]+parent=$(ps -o ppid= -p $$)\n[\s]+name=$(ps -o comm= -p $parent)\n[\s]+case\n"$name" in sshd|login) exec tmux ;; esac\nfi

The single line behavior[0] mitght affect matching of \n.

[0] https://github.com/OVALProject/Language/blob/master/docs/independent-definitions-schema.md#-textfilecontent54behaviors-

@comps
Copy link
Collaborator Author

comps commented Oct 2, 2019

The single line behavior[0] mitght affect matching of \n.

[0] https://github.com/OVALProject/Language/blob/master/docs/independent-definitions-schema.md#-textfilecontent54behaviors-

I think we want single-line matching here. This IIUC takes the whole file content and matches against it. Multiline mode basically takes it line-by-line and applies the regex on each line.

I'll update and test the OVAL on my end.

@comps
Copy link
Collaborator Author

comps commented Oct 2, 2019

What kind of matching does OVAL do? ... It seems to be using Perl rules for single/multi line, so I rewrote the regexp to match Perl standards (and I tested it as working using perl), but xccdf eval fails on it:
if \[ "\$PS1" \]; then\n\s+parent=\$\(ps -o ppid= -p \$\$\)\n\s+name=\$\(ps -o comm= -p \$parent\)\n\s+case "\$name" in sshd\|login\) exec tmux ;; esac\nfi

Is this somehow related to <ind:pattern operation="pattern match">([^\n]+)\s*$</ind:pattern> in obj_configure_bashrc_exec_tmux?

@yuumasato
Copy link
Member

@comps Could you push the regex? So I can try to debug and check the objects collected and to what regex it is trying to match?

Copy link
Member

@yuumasato yuumasato left a comment

Choose a reason for hiding this comment

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

The test is capturing only the last line as the object of evaluation.
Changing pattern in line 26 to ^(.*)$ will capture the whole file as a single object.

And the operation in the state needs to be pattern match.

This prevents tmux-inside-tmux for common use cases like `su -'.

Signed-off-by: Jiri Jaburek <jjaburek@redhat.com>
@comps
Copy link
Collaborator Author

comps commented Oct 3, 2019

Thanks for the help. Everything should be in its final form, I tested the check for pass/fail and remediation - seems to be working.

@comps comps marked this pull request as ready for review October 3, 2019 12:05
@yuumasato
Copy link
Member

@comps Thanks for the PR.

One more thing, I forgot, was focused on OVAL.
Do you think it makes sense to also reflect this change in the rule description?

@comps
Copy link
Collaborator Author

comps commented Oct 3, 2019

I believe I did change ocil to match the new algorithm (please double check). I don't see anything from the actual description that would need changing.

@yuumasato yuumasato self-assigned this Oct 3, 2019
@yuumasato yuumasato added this to the 0.1.47 milestone Oct 3, 2019
@yuumasato
Copy link
Member

Cool, thank again for the patch!

@yuumasato yuumasato merged commit 74decaf into ComplianceAsCode:master Oct 3, 2019
@yuumasato yuumasato mentioned this pull request Oct 8, 2019
This pull request was closed.
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.

2 participants