MCPcopy Index your code
hub / github.com/RustPython/RustPython / _security_check

Method _security_check

Lib/netrc.py:157–171  ·  view source on GitHub ↗
(self, fp, default_netrc, login)

Source from the content-addressed store, hash-verified

155 self._security_check(fp, default_netrc, self.hosts[entryname][0])
156
157 def _security_check(self, fp, default_netrc, login):
158 if _can_security_check() and default_netrc and login != "anonymous":
159 prop = os.fstat(fp.fileno())
160 current_user_id = os.getuid()
161 if prop.st_uid != current_user_id:
162 fowner = _getpwuid(prop.st_uid)
163 user = _getpwuid(current_user_id)
164 raise NetrcParseError(
165 (f"~/.netrc file owner ({fowner}, {user}) does not match"
166 " current user"))
167 if (prop.st_mode & (stat.S_IRWXG | stat.S_IRWXO)):
168 raise NetrcParseError(
169 "~/.netrc access too permissive: access"
170 " permissions must restrict access to only"
171 " the owner")
172
173 def authenticators(self, host):
174 """Return a (user, account, password) tuple for given host."""

Callers 1

_parseMethod · 0.95

Calls 4

_can_security_checkFunction · 0.85
_getpwuidFunction · 0.85
NetrcParseErrorClass · 0.85
filenoMethod · 0.45

Tested by

no test coverage detected