rspec/rules/S2612/python/rule.adoc

58 lines
1.3 KiB
Plaintext
Raw Normal View History

2021-01-20 04:06:26 +00:00
include::../description.adoc[]
include::../ask-yourself.adoc[]
include::../recommended.adoc[]
== Sensitive Code Example
For https://docs.python.org/3/library/os.html#os.umask[os.umask]:
----
os.umask(0) # Sensitive
----
For https://docs.python.org/3/library/os.html#os.chmod[os.chmod], https://docs.python.org/3/library/os.html#os.lchmod[os.lchmod], and https://docs.python.org/3/library/os.html#os.fchmod[os.fchmod]:
----
os.chmod("/tmp/fs", stat.S_IRWXO) # Sensitive
os.lchmod("/tmp/fs", stat.S_IRWXO) # Sensitive
os.fchmod(fd, stat.S_IRWXO) # Sensitive
----
== Compliant Solution
For https://docs.python.org/3/library/os.html#os.umask[os.umask]:
2022-02-04 17:28:24 +01:00
[source,python]
2021-01-20 04:06:26 +00:00
----
os.umask(0o777)
2021-01-20 04:06:26 +00:00
----
For https://docs.python.org/3/library/os.html#os.chmod[os.chmod], https://docs.python.org/3/library/os.html#os.lchmod[os.lchmod], and https://docs.python.org/3/library/os.html#os.fchmod[os.fchmod]:
2022-02-04 17:28:24 +01:00
[source,python]
2021-01-20 04:06:26 +00:00
----
os.chmod("/tmp/fs", stat.S_IRWXU)
os.lchmod("/tmp/fs", stat.S_IRWXU)
os.fchmod(fd, stat.S_IRWXU)
2021-01-20 04:06:26 +00:00
----
include::../see.adoc[]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]