Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F41651122
find-tools-with-no-unblocked-maintainers.py
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Authored By
bd808
Jan 5 2024, 2:19 AM
2024-01-05 02:19:54 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
find-tools-with-no-unblocked-maintainers.py
View Options
# SPDX-License-Identifier: AGPL-3.0
# (c) Taavi Väänänen <hi@taavi.wtf>, 2022
# (c) Bryan Davis <bd808@wikimedia.org>, 2024
import
ldap3
import
yaml
with
open
(
"/etc/ldap.yaml"
,
"r"
)
as
f
:
ldap_config
=
yaml
.
safe_load
(
f
.
read
())
conn
=
ldap3
.
Connection
(
ldap_config
[
"servers"
],
user
=
ldap_config
[
"user"
],
password
=
ldap_config
[
"password"
],
auto_bind
=
True
,
auto_range
=
True
,
read_only
=
True
,
)
not_locked_toolforge_users
=
[
f
'uid={user["attributes"]["uid"][0]},ou=people,dc=wikimedia,dc=org'
for
user
in
conn
.
extend
.
standard
.
paged_search
(
"ou=people,dc=wikimedia,dc=org"
,
"(&(objectclass=posixAccount)(memberOf=cn=project-tools,ou=groups,dc=wikimedia,dc=org)(!(pwdPolicySubentry=cn=disabled,ou=ppolicies,dc=wikimedia,dc=org)))"
,
attributes
=
[
"uid"
],
time_limit
=
5
,
paged_size
=
256
,
generator
=
True
,
)
]
tools
=
conn
.
extend
.
standard
.
paged_search
(
"ou=servicegroups,dc=wikimedia,dc=org"
,
"(&(objectClass=groupOfNames)(cn=tools.*))"
,
attributes
=
[
"cn"
,
"member"
],
time_limit
=
5
,
paged_size
=
256
,
generator
=
True
,
)
disabled_tools
=
[
tool
[
"attributes"
][
"cn"
][
0
]
for
tool
in
conn
.
extend
.
standard
.
paged_search
(
"ou=servicegroups,dc=wikimedia,dc=org"
,
"(&(objectClass=posixAccount)(pwdPolicySubentry=cn=disabled,ou=ppolicies,dc=wikimedia,dc=org))"
,
attributes
=
[
"cn"
],
paged_size
=
256
,
time_limit
=
5
,
generator
=
True
,
)
]
for
tool
in
tools
:
tool_name
=
tool
[
"attributes"
][
"cn"
][
0
]
if
tool_name
in
disabled_tools
:
continue
found
=
False
for
maintainer
in
tool
[
"attributes"
][
"member"
]:
if
maintainer
in
not_locked_toolforge_users
:
found
=
True
break
if
not
found
:
print
(
tool_name
)
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14451523
Default Alt Text
find-tools-with-no-unblocked-maintainers.py (1 KB)
Attached To
Mode
P35381 find-tools-with-no-unblocked-maintainers.py
Attached
Detach File
Event Timeline
Log In to Comment