Skip to content

Create hello11.py - #106

Open
vishnu-deepsource wants to merge 1 commit into
masterfrom
copy-of-pr-104
Open

Create hello11.py#106
vishnu-deepsource wants to merge 1 commit into
masterfrom
copy-of-pr-104

Conversation

@vishnu-deepsource

Copy link
Copy Markdown

Copy of #104

@deepsource-development

deepsource-development Bot commented Jun 1, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 9d1323c...6ad95cc on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

Code Review Summary

Analyzer Status Updated (UTC) Details
Ansible Jun 1, 2026 3:54p.m. Review ↗
Helm Jun 1, 2026 3:54p.m. Review ↗
Python Jun 1, 2026 3:54p.m. Review ↗
Secrets Jun 1, 2026 3:54p.m. Review ↗

Comment thread hello11.py
sorted(value, key=lambda k: len(k))

f = open("/tmp/.deepsource.toml", "r")
f.write("config file.")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Writing to file opened without write mode causes IOError


The f.write("config file.") operation is performed on a file that is likely opened without a write mode (w, a, or x). This causes an IOError since write operations require appropriate file opening modes. This prevents the file content from being updated as intended.

Open the file using a write mode like w to allow f.write() to succeed without errors and properly update file contents.

Comment thread hello11.py
f.close()


def moon_chooser(moon, moons=["europa", "callisto", "phobos"]):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Mutable default `moons` list causes shared state bugs


Using a mutable default value like the list assigned to the moons parameter means the same list object is reused on every function call. This can cause unexpected side effects when the list is modified, as changes persist across calls and affect all usages.

Replace the default list with None and inside the function assign a new list if the argument is None. This approach isolates each call with its own fresh list, avoiding shared state issues.

Comment thread hello11.py


def tar_something():
os.tempnam("dir1")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Use of `os.tempnam()` allows symlink attack vulnerabilities


The code calls os.tempnam("dir1"), which generates a temporary filename vulnerable to symlink attacks. An attacker could replace the file with a symbolic link, leading to unauthorized file modification or data leaks.
Replace os.tempnam() with os.tmpfile() or the tempfile module which securely creates temporary files preventing symlink race conditions.

Comment thread hello11.py
def tar_something():
os.tempnam("dir1")
subprocess.Popen("/bin/chown *", shell=True)
o.system("/bin/tar xvzf *")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Undefined `o` variable causes runtime error


The variable o is used to call system but is never defined or imported, which results in a runtime error preventing the command from executing. This stops the intended extraction operation from running properly.
Define or import the variable o properly before using it, commonly this is the os module for system calls or another appropriate context object.

Comment thread hello11.py
self.limits = (1, 10)

def get_number(self, min_max):
raise NotImplemented

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

`raise NotImplemented` throws `TypeError` unexpectedly


BaseNumberGenerator.get_number raises NotImplemented, which is invalid for raise. This causes confusing TypeError behavior and obscures contract violations.

Replace with raise NotImplementedError() to signal unimplemented abstract behavior correctly.

Comment thread hello11.py
Comment on lines +121 to +122
f = open("/tmp/.deepsource.toml", "r")
f.write("config file.")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

`open(..., "r")` then `write()` crashes module entry path


Top-level script code opens /tmp/.deepsource.toml in read mode and writes to it. Running the file directly will raise an exception immediately.

Use with open(path, "w") as f: so startup logic proceeds predictably.

@vishnu-deepsource

Copy link
Copy Markdown
Author

@deepsourcebot review this

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.

1 participant