-
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
[device/centec] Replace os.system and remove subprocess with shell=True #12024
Conversation
Signed-off-by: maipbui <maibui@microsoft.com>
os.system('echo out > /sys/class/gpio/gpio502/direction') | ||
os.system('echo 1 > /sys/class/gpio/gpio502/value') | ||
with open('/sys/class/gpio/export', 'w') as file: | ||
file.write('502') |
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.
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.
I added \n
, thank you.
Signed-off-by: maipbui <maibui@microsoft.com>
/azp run Azure.sonic-buildimage |
Azure Pipelines successfully started running 1 pipeline(s). |
@LuiSzee @guxianghong @taochengyi @yangbashuang |
Ok, we will review and verify it on centec platform. |
subprocess.run not work on older version SONiC image, such as 201911
|
Signed-off-by: maipbui <maibui@microsoft.com>
@LuiSzee I changed it to |
@LuiSzee @guxianghong @taochengyi @yangbashuang Do you have any further comments? |
@maipbui I have verified it on centec platform. |
Related work items: sonic-net#2151, sonic-net#2194, sonic-net#2224, sonic-net#2237, sonic-net#2264, sonic-net#2281, sonic-net#2286, sonic-net#2297, sonic-net#2299, sonic-net#2305, sonic-net#2325, sonic-net#2335, sonic-net#2338, sonic-net#2341, sonic-net#2343, sonic-net#2347, sonic-net#2350, sonic-net#2355, sonic-net#2356, sonic-net#2358, sonic-net#2360, sonic-net#2363, sonic-net#2367, sonic-net#2368, sonic-net#2370, sonic-net#2374, sonic-net#2392, sonic-net#2398, sonic-net#2408, sonic-net#2414, sonic-net#2415, sonic-net#2419, sonic-net#2421, sonic-net#2422, sonic-net#2423, sonic-net#2426, sonic-net#2427, sonic-net#2430, sonic-net#2431, sonic-net#2433, sonic-net#2434, sonic-net#2436, sonic-net#2437, sonic-net#2441, sonic-net#2444, sonic-net#2445, sonic-net#2446, sonic-net#2456, sonic-net#2458, sonic-net#2460, sonic-net#2461, sonic-net#2463, sonic-net#2472, sonic-net#2475, sonic-net#11877, sonic-net#12024, sonic-net#12065, sonic-net#12097, sonic-net#12130, sonic-net#12209, sonic-net#12217, sonic-net#12244, sonic-net#12251, sonic-net#12255, sonic-net#12276, sonic-net#12284
Signed-off-by: maipbui maibui@microsoft.com
Why I did it
subprocess.Popen()
andsubprocess.run()
is used withshell=True
, which is very dangerous for shell injection.os
- not secure against maliciously constructed input and dangerous if used to evaluate dynamic contentHow I did it
Replace
os
bysubprocess
, removeshell=True
Remove unused functions
How to verify it
Which release branch to backport (provide reason below if selected)
Description for the changelog
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)