Skip to content

[sonic_package_manager] replace shell=True#2726

Merged
qiluo-msft merged 4 commits intosonic-net:masterfrom
maipbui:pkg_mngr_pysec
Apr 20, 2023
Merged

[sonic_package_manager] replace shell=True#2726
qiluo-msft merged 4 commits intosonic-net:masterfrom
maipbui:pkg_mngr_pysec

Conversation

@maipbui
Copy link
Contributor

@maipbui maipbui commented Mar 7, 2023

What I did

subprocess() - when using with shell=True is dangerous. Using subprocess function without a static string can lead to command injection.

How I did it

subprocess() - use shell=False instead, use list of strings Ref: https://semgrep.dev/docs/cheat-sheets/python-command-injection/#mitigation

How to verify it

Pass UT

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

Signed-off-by: maipbui <[email protected]>


def run_command(command: str):
def run_command(command: List[str]):
Copy link
Contributor

@qiluo-msft qiluo-msft Mar 9, 2023

Choose a reason for hiding this comment

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

Please be aware type hint does not mean runtime check: https://stackoverflow.com/questions/41692473/does-python-type-hint-annotations-cause-some-run-time-effects. Will you add a runtime check?
#Closed

maipbui added 2 commits April 6, 2023 04:08
Signed-off-by: Mai Bui <[email protected]>
Signed-off-by: Mai Bui <[email protected]>
@qiluo-msft
Copy link
Contributor

@stepanblyschak Could you help review?

qiluo-msft
qiluo-msft previously approved these changes Apr 6, 2023
stepanblyschak
stepanblyschak previously approved these changes Apr 19, 2023
Signed-off-by: Mai Bui <[email protected]>
@maipbui maipbui dismissed stale reviews from stepanblyschak and qiluo-msft via 45e6d96 April 20, 2023 15:35
@qiluo-msft qiluo-msft merged commit 5e99edb into sonic-net:master Apr 20, 2023
@maipbui maipbui deleted the pkg_mngr_pysec branch April 20, 2023 18:08
dprital added a commit to dprital/sonic-buildimage that referenced this pull request May 1, 2023
Update sonic-utilities submodule pointer to include the following:
* 88ffb16 [config]config reload should generate sysinfo if missing ([sonic-net#2778](sonic-net/sonic-utilities#2778))
* 7443b9e [sonic-package-manager] support extension with multiple YANG modules ([sonic-net#2752](sonic-net/sonic-utilities#2752))
* 522c3a9 [sonic-package-manager] add support for multiple CLI plugin files ([sonic-net#2753](sonic-net/sonic-utilities#2753))
* b38fcfd [show][muxcable] fix  RC ([sonic-net#2812](sonic-net/sonic-utilities#2812))
* 7e24463 [chassis]: remote cli commands infra for sonic chassis ([sonic-net#2701](sonic-net/sonic-utilities#2701))
* bee593e [DPB]Fixing typo in config breakout output ([sonic-net#2802](sonic-net/sonic-utilities#2802))
* ada603c [config]Support multi-asic  Golden Config override ([sonic-net#2738](sonic-net/sonic-utilities#2738))
* 88a7daa [show][barefoot] replace shell=True ([sonic-net#2699](sonic-net/sonic-utilities#2699))
* 5e99edb [sonic_package_manager] replace shell=True ([sonic-net#2726](sonic-net/sonic-utilities#2726))
* b547bb4 [acl-loader] Only add default deny rule when table is L3 or L3V6 ([sonic-net#2796](sonic-net/sonic-utilities#2796))

Signed-off-by: dprital <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants