Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
user-discovery-bot
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
archives
user-discovery-bot
Commits
f4f91b07
Commit
f4f91b07
authored
Jan 12, 2022
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Improve documentation
parent
f524b8da
No related branches found
No related tags found
4 merge requests
!50
Revert "update deps"
,
!48
Release
,
!42
Add username field to users table for raw username
,
!41
Xx 3692/banned users
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
cmd/params.go
+1
-0
1 addition, 0 deletions
cmd/params.go
cmd/root.go
+2
-0
2 additions, 0 deletions
cmd/root.go
storage/storage.go
+3
-0
3 additions, 0 deletions
storage/storage.go
with
6 additions
and
0 deletions
cmd/params.go
+
1
−
0
View file @
f4f91b07
...
@@ -45,6 +45,7 @@ func InitParams(vip *viper.Viper) params.General {
...
@@ -45,6 +45,7 @@ func InitParams(vip *viper.Viper) params.General {
jww
.
FATAL
.
Fatalf
(
"Failed to read session path: %+v"
,
err
)
jww
.
FATAL
.
Fatalf
(
"Failed to read session path: %+v"
,
err
)
}
}
// Load banned user CSV
bannedUserList
,
err
:=
utils
.
ReadFile
(
viper
.
GetString
(
"bannedUserList"
))
bannedUserList
,
err
:=
utils
.
ReadFile
(
viper
.
GetString
(
"bannedUserList"
))
if
err
!=
nil
{
if
err
!=
nil
{
jww
.
WARN
.
Printf
(
"Failed to read banned user list: %v"
,
err
)
jww
.
WARN
.
Printf
(
"Failed to read banned user list: %v"
,
err
)
...
...
This diff is collapsed.
Click to expand it.
cmd/root.go
+
2
−
0
View file @
f4f91b07
...
@@ -44,6 +44,7 @@ var rootCmd = &cobra.Command{
...
@@ -44,6 +44,7 @@ var rootCmd = &cobra.Command{
initLog
()
initLog
()
p
:=
InitParams
(
viper
.
GetViper
())
p
:=
InitParams
(
viper
.
GetViper
())
// Process CSV into a map
bannedUsers
:=
make
(
map
[
string
]
struct
{})
bannedUsers
:=
make
(
map
[
string
]
struct
{})
if
p
.
BannedUserList
!=
""
{
if
p
.
BannedUserList
!=
""
{
bannedUserList
:=
strings
.
Split
(
p
.
BannedUserList
,
","
)
bannedUserList
:=
strings
.
Split
(
p
.
BannedUserList
,
","
)
...
@@ -52,6 +53,7 @@ var rootCmd = &cobra.Command{
...
@@ -52,6 +53,7 @@ var rootCmd = &cobra.Command{
}
}
}
}
// Initialize storage
storage
,
err
:=
storage
.
NewStorage
(
p
.
DbUsername
,
p
.
DbPassword
,
p
.
DbName
,
p
.
DbAddress
,
p
.
DbPort
,
bannedUsers
)
storage
,
err
:=
storage
.
NewStorage
(
p
.
DbUsername
,
p
.
DbPassword
,
p
.
DbName
,
p
.
DbAddress
,
p
.
DbPort
,
bannedUsers
)
if
err
!=
nil
{
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to initialize storage interface: %+v"
,
err
)
jww
.
FATAL
.
Panicf
(
"Failed to initialize storage interface: %+v"
,
err
)
...
...
This diff is collapsed.
Click to expand it.
storage/storage.go
+
3
−
0
View file @
f4f91b07
...
@@ -32,11 +32,14 @@ func NewStorage(username, password, dbName, address, port string, bannedUserList
...
@@ -32,11 +32,14 @@ func NewStorage(username, password, dbName, address, port string, bannedUserList
return
storage
,
err
return
storage
,
err
}
}
// IsBanned checks if the username is in Storage's bannedUserList.
func
(
s
*
Storage
)
IsBanned
(
username
string
)
bool
{
func
(
s
*
Storage
)
IsBanned
(
username
string
)
bool
{
_
,
exists
:=
s
.
bannedUserList
[
username
]
_
,
exists
:=
s
.
bannedUserList
[
username
]
return
exists
return
exists
}
}
// SetBanned is a testing only helper function which sets a username
// in Storage's bannedUserList.
func
(
s
*
Storage
)
SetBanned
(
username
string
,
t
*
testing
.
T
)
{
func
(
s
*
Storage
)
SetBanned
(
username
string
,
t
*
testing
.
T
)
{
if
t
==
nil
{
if
t
==
nil
{
jww
.
FATAL
.
Panic
(
"Cannot use this outside of testing"
)
jww
.
FATAL
.
Panic
(
"Cannot use this outside of testing"
)
...
...
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