Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cppack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
passwords
cppack
Commits
f05a06d6
Commit
f05a06d6
authored
Feb 4, 2020
by
Mathieu Valois
Browse files
Options
Downloads
Patches
Plain Diff
more object-oriented code
parent
9387b23c
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/ThreadData.h
+64
-0
64 additions, 0 deletions
include/ThreadData.h
src/core/ThreadData.cpp
+59
-0
59 additions, 0 deletions
src/core/ThreadData.cpp
with
123 additions
and
0 deletions
include/ThreadData.h
0 → 100644
+
64
−
0
View file @
f05a06d6
#ifndef THREAD_DATA_H
#define THREAD_DATA_H
#include
<string>
#include
<unordered_map>
#include
<queue>
#include
<climits>
#include
<regex>
#include
"Policy.h"
#include
"SecurityRules.h"
typedef
std
::
unordered_map
<
std
::
string
,
uint64_t
>
StringOccurrence
;
typedef
std
::
unordered_map
<
int
,
uint64_t
>
IntOccurrence
;
/**
* @brief minimal number of digits of a password, etc.
*/
class
minMax
{
public:
void
updateMinMax
(
const
Policy
&
pol
);
uint
mindigit
=
UINT_MAX
;
uint
maxdigit
=
0
;
uint
minlower
=
UINT_MAX
;
uint
maxlower
=
0
;
uint
minupper
=
UINT_MAX
;
uint
maxupper
=
0
;
uint
minspecial
=
UINT_MAX
;
uint
maxspecial
=
0
;
};
class
ThreadData
{
public:
ThreadData
operator
+
(
const
ThreadData
&
other
);
ThreadData
operator
+=
(
const
ThreadData
&
other
)
const
;
int
thread_id
;
std
::
string
filename
;
uint64_t
lineBegin
=
0
;
uint64_t
lineEnd
=
0
;
uint64_t
total_counter
=
0
;
uint64_t
total_filter
=
0
;
IntOccurrence
length
;
StringOccurrence
simplemasks
;
StringOccurrence
advancedmasks
;
StringOccurrence
charactersets
;
std
::
queue
<
std
::
string
>
password_queue
;
minMax
minMaxValue
;
std
::
regex
current_regex
;
bool
use_regex
=
false
;
bool
withcount
=
false
;
uint
limitSimplemask
;
uint
limitAdvancedmask
;
SecurityRules
sr
;
bool
finished
=
false
;
};
#endif // THREAD_DATA_H
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/core/ThreadData.cpp
0 → 100644
+
59
−
0
View file @
f05a06d6
#include
"ThreadData.h"
#include
<iostream>
using
namespace
std
;
void
minMax
::
updateMinMax
(
const
Policy
&
pol
)
{
mindigit
=
std
::
min
(
mindigit
,
pol
.
digit
);
maxdigit
=
std
::
max
(
maxdigit
,
pol
.
digit
);
minlower
=
std
::
min
(
minlower
,
pol
.
lower
);
maxlower
=
std
::
max
(
maxlower
,
pol
.
lower
);
minupper
=
std
::
min
(
minupper
,
pol
.
upper
);
maxupper
=
std
::
max
(
maxupper
,
pol
.
upper
);
minspecial
=
std
::
min
(
minspecial
,
pol
.
special
);
maxspecial
=
std
::
max
(
maxspecial
,
pol
.
special
);
}
ThreadData
ThreadData
::
operator
+=
(
const
ThreadData
&
other
)
const
{
return
ThreadData
(
*
this
)
+
other
;
}
ThreadData
ThreadData
::
operator
+
(
const
ThreadData
&
other
){
total_counter
+=
other
.
total_counter
;
total_filter
+=
other
.
total_filter
;
Policy
min
,
max
;
min
.
digit
=
other
.
minMaxValue
.
mindigit
;
min
.
lower
=
other
.
minMaxValue
.
minlower
;
min
.
upper
=
other
.
minMaxValue
.
minupper
;
min
.
special
=
other
.
minMaxValue
.
minspecial
;
max
.
digit
=
other
.
minMaxValue
.
maxdigit
;
max
.
lower
=
other
.
minMaxValue
.
maxlower
;
max
.
upper
=
other
.
minMaxValue
.
maxupper
;
max
.
special
=
other
.
minMaxValue
.
maxspecial
;
sr
.
nbSecurePassword
+=
other
.
sr
.
nbSecurePassword
;
minMaxValue
.
updateMinMax
(
min
);
minMaxValue
.
updateMinMax
(
max
);
for
(
std
::
pair
<
int
,
uint64_t
>
occ
:
other
.
length
){
length
[
occ
.
first
]
+=
occ
.
second
;
}
for
(
std
::
pair
<
std
::
string
,
int
>
occ
:
other
.
charactersets
){
charactersets
[
occ
.
first
]
+=
occ
.
second
;
}
for
(
std
::
pair
<
std
::
string
,
int
>
occ
:
other
.
simplemasks
){
simplemasks
[
occ
.
first
]
+=
occ
.
second
;
}
for
(
std
::
pair
<
std
::
string
,
int
>
occ
:
other
.
advancedmasks
){
advancedmasks
[
occ
.
first
]
+=
occ
.
second
;
}
return
*
this
;
}
\ No newline at end of file
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