Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
ghc-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ben Gamari
ghc-utils
Commits
fe03c79b
Commit
fe03c79b
authored
2 years ago
by
Ben Gamari
Browse files
Options
Downloads
Patches
Plain Diff
gitlab-utils/spam_util: Update gitlab-python
parent
c696e476
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gitlab-utils/gitlab_utils/spam_util.py
+5
-5
5 additions, 5 deletions
gitlab-utils/gitlab_utils/spam_util.py
with
5 additions
and
5 deletions
gitlab-utils/gitlab_utils/spam_util.py
+
5
−
5
View file @
fe03c79b
...
@@ -53,7 +53,7 @@ def cli():
...
@@ -53,7 +53,7 @@ def cli():
@click.option
(
'
-o
'
,
'
--output
'
,
type
=
click
.
File
(
'
w
'
))
@click.option
(
'
-o
'
,
'
--output
'
,
type
=
click
.
File
(
'
w
'
))
def
dump_snippets
(
output
)
->
None
:
def
dump_snippets
(
output
)
->
None
:
gl
=
gitlab
.
Gitlab
.
from_config
()
gl
=
gitlab
.
Gitlab
.
from_config
()
with
click
.
progressbar
(
gl
.
snippets
.
public
(
as_list
=
Fals
e
,
all
=
True
,
lazy
=
True
),
label
=
'
Listing spam snippets
'
)
as
snippets
:
with
click
.
progressbar
(
gl
.
snippets
.
public
(
iterator
=
Tru
e
,
all
=
True
,
lazy
=
True
),
label
=
'
Listing spam snippets
'
)
as
snippets
:
for
x
in
snippets
:
for
x
in
snippets
:
u
=
gl
.
users
.
get
(
x
.
author
[
'
id
'
])
u
=
gl
.
users
.
get
(
x
.
author
[
'
id
'
])
if
not
good_user
(
gl
,
u
):
if
not
good_user
(
gl
,
u
):
...
@@ -71,7 +71,7 @@ def parse_user_list(input) -> Iterator[UserName]:
...
@@ -71,7 +71,7 @@ def parse_user_list(input) -> Iterator[UserName]:
@click.option
(
'
-o
'
,
'
--output
'
,
type
=
click
.
File
(
'
w
'
))
@click.option
(
'
-o
'
,
'
--output
'
,
type
=
click
.
File
(
'
w
'
))
def
list_bad_users
(
output
)
->
None
:
def
list_bad_users
(
output
)
->
None
:
gl
=
gitlab
.
Gitlab
.
from_config
()
gl
=
gitlab
.
Gitlab
.
from_config
()
with
click
.
progressbar
(
gl
.
users
.
list
(
as_list
=
Fals
e
,
all
=
True
,
lazy
=
True
),
label
=
'
Listing users
'
)
as
users
:
with
click
.
progressbar
(
gl
.
users
.
list
(
iterator
=
Tru
e
,
all
=
True
,
lazy
=
True
),
label
=
'
Listing users
'
)
as
users
:
for
user
in
users
:
for
user
in
users
:
try
:
try
:
if
user
.
username
in
USER_WHITELIST
:
if
user
.
username
in
USER_WHITELIST
:
...
@@ -89,7 +89,7 @@ def find_bad_projects(output) -> None:
...
@@ -89,7 +89,7 @@ def find_bad_projects(output) -> None:
'
-phuc-
'
,
'
-tai-
'
,
'
-app-
'
,
'
thuyet-
'
,
'
-ly-
'
,
'
huong
'
'
-phuc-
'
,
'
-tai-
'
,
'
-app-
'
,
'
thuyet-
'
,
'
-ly-
'
,
'
huong
'
}
}
gl
=
gitlab
.
Gitlab
.
from_config
()
gl
=
gitlab
.
Gitlab
.
from_config
()
with
click
.
progressbar
(
gl
.
projects
.
list
(
as_list
=
Fals
e
,
all
=
True
,
lazy
=
True
),
label
=
'
Listing projects
'
)
as
projects
:
with
click
.
progressbar
(
gl
.
projects
.
list
(
iterator
=
Tru
e
,
all
=
True
,
lazy
=
True
),
label
=
'
Listing projects
'
)
as
projects
:
for
proj
in
projects
:
for
proj
in
projects
:
try
:
try
:
if
proj
.
owner
[
'
username
'
]
in
USER_WHITELIST
:
if
proj
.
owner
[
'
username
'
]
in
USER_WHITELIST
:
...
@@ -129,7 +129,7 @@ def good_user(gl, u) -> bool:
...
@@ -129,7 +129,7 @@ def good_user(gl, u) -> bool:
@click.option
(
'
--dryrun
'
,
is_flag
=
True
)
@click.option
(
'
--dryrun
'
,
is_flag
=
True
)
def
reject_pending_requests
(
dryrun
:
bool
):
def
reject_pending_requests
(
dryrun
:
bool
):
gl
=
gitlab
.
Gitlab
.
from_config
()
gl
=
gitlab
.
Gitlab
.
from_config
()
with
click
.
progressbar
(
gl
.
users
.
list
(
as_list
=
Fals
e
,
all
=
True
,
lazy
=
True
,
without_projects
=
True
),
label
=
'
Listing users
'
)
as
users
:
with
click
.
progressbar
(
gl
.
users
.
list
(
iterator
=
Tru
e
,
all
=
True
,
lazy
=
True
,
without_projects
=
True
),
label
=
'
Listing users
'
)
as
users
:
for
u
in
users
:
for
u
in
users
:
if
u
.
state
==
'
blocked_pending_approval
'
:
if
u
.
state
==
'
blocked_pending_approval
'
:
logging
.
info
(
f
'
Rejecting approval request for
{
u
.
username
}
'
)
logging
.
info
(
f
'
Rejecting approval request for
{
u
.
username
}
'
)
...
@@ -190,7 +190,7 @@ def inactive_user(gl, u, thresh: timedelta = timedelta(days=180)) -> bool:
...
@@ -190,7 +190,7 @@ def inactive_user(gl, u, thresh: timedelta = timedelta(days=180)) -> bool:
@click.option
(
'
-o
'
,
'
--output
'
,
type
=
click
.
File
(
'
w
'
))
@click.option
(
'
-o
'
,
'
--output
'
,
type
=
click
.
File
(
'
w
'
))
def
list_inactive_users
(
output
)
->
None
:
def
list_inactive_users
(
output
)
->
None
:
gl
=
gitlab
.
Gitlab
.
from_config
()
gl
=
gitlab
.
Gitlab
.
from_config
()
with
click
.
progressbar
(
gl
.
users
.
list
(
as_list
=
Fals
e
,
all
=
True
,
lazy
=
True
),
label
=
'
Listing inactive users
'
)
as
users
:
with
click
.
progressbar
(
gl
.
users
.
list
(
iterator
=
Tru
e
,
all
=
True
,
lazy
=
True
),
label
=
'
Listing inactive users
'
)
as
users
:
for
u
in
users
:
for
u
in
users
:
if
inactive_user
(
gl
,
u
)
and
not
good_user
(
gl
,
u
):
if
inactive_user
(
gl
,
u
)
and
not
good_user
(
gl
,
u
):
output
.
write
(
'
%-20s # %s
\n
'
%
(
u
.
username
,
u
.
last_sign_in_at
))
output
.
write
(
'
%-20s # %s
\n
'
%
(
u
.
username
,
u
.
last_sign_in_at
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment