-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[containercfgd] Add containercfgd and syslog rate limit configuration support #12489
Conversation
containercfgd.ContainerConfigDaemon.register_handler('LoadMock', mock_handler_cls) | ||
daemon = containercfgd.ContainerConfigDaemon() | ||
daemon.init_data_handler({}) | ||
mock_handler_instance.handle_init_data.assert_called_once |
Check notice
Code scanning / CodeQL
Statement has no effect
4098f04
to
b6800d6
Compare
Build issue pending on PR #12510 |
/azp run Azure.sonic-buildimage |
Azure Pipelines successfully started running 1 pipeline(s). |
/azpw run Azure.sonic-buildimag |
/AzurePipelines run Azure.sonic-buildimag |
No pipelines are associated with this pull request. |
/AzurePipelines run Azure.sonic-buildimag |
No pipelines are associated with this pull request. |
/azprun Azure.sonic-buildimage |
/azp run Azure.sonic-buildimage |
Azure Pipelines successfully started running 1 pipeline(s). |
/azpw run Azure.sonic-buildimage |
/AzurePipelines run Azure.sonic-buildimage |
Azure Pipelines successfully started running 1 pipeline(s). |
/azpw run Azure.sonic-buildimage |
Azure Pipelines successfully started running 1 pipeline(s). |
/azpw run Azure.sonic-buildimage |
/AzurePipelines run Azure.sonic-buildimage |
Azure Pipelines successfully started running 1 pipeline(s). |
Hi @saiarcot895, could you please kindly help review this? |
output = run_command('sonic-cfggen -d -t /usr/share/sonic/templates/rsyslog-container.conf.j2 -a "{{\\"target_ip\\": \\"{}\\", \\"container_name\\": \\"{}\\" }}"'.format(self.target_ip, container_name)) | ||
f.write(output) | ||
run_command('cp {} {}'.format(self.TMP_SYSLOG_CONF_PATH, self.SYSLOG_CONF_PATH)) | ||
run_command("supervisorctl restart rsyslogd") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these be split into individual entries (such as ["cp", self.TMP_SYSLOG_CONF_PATH, self.SYSLOG_CONF_PATH]
and passed directly into subprocess.check_output
instead of using shlex.split
? That will prevent code injections from outside sources doing something that shouldn't be done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @saiarcot895 , thanks for the comment. I suppose shlex.split
will split cp /tmp/file /tmp/file_copy
into ['cp', '/tmp/file', '/tmp/file_copy']
, it also prevents code injections. And the benefit is that:
- The original command is a complete string which is more readable than a list
shlex.split
will do the split for user automatically which prevent user from incorrectly splitting command.
So, I prefer to keep this. What do you say?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, because it's split into an array, the first token will always be the command that gets executed. However, if, hypothetically, self.TMP_SYSLOG_CONF_PATH
was /tmp/file name
, then shlex.split
will split cp /tmp/file name /tmp/file_copy
into ["cp", "/tmp/file", "name", "/tmp/file_copy"]
, which is incorrect.
I think considering we know what these arguments should be, just doing the splitting ourselves would be better. (It would also make the JSON argument a couple lines above this a bit easier to read).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
/azpw run Azure.sonic-buildimage |
/AzurePipelines run Azure.sonic-buildimage |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list. |
… support (sonic-net#12489) * [containercfgd] Add containercfgd and syslog rate limit configuration support * Fix build issue * Fix checker issue * Fix review comment * Fix review comment * Update containercfgd.py
Cherry-pick PR to 202211: #13361 |
…guration support (sonic-net#12489)" This reverts commit 3b3837a.
HLD: sonic-net/SONiC#1049
Why I did it
Add a containercfgd to handler container side CONFIG DB changes
How I did it
How to verify it
unit test
Which release branch to backport (provide reason below if selected)
Description for the changelog
Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)