Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bobgroup-go-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bob Public Utils
bobgroup-go-utils
Commits
83f5be4c
Commit
83f5be4c
authored
3 years ago
by
Ruaan Burger
Browse files
Options
Downloads
Patches
Plain Diff
Prevent false positives when dealing with heavily nested objects
parent
93bf3aa2
No related branches found
No related tags found
1 merge request
!26
Prevent false positives when dealing with heavily nested objects
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
audit/audit.go
+15
-3
15 additions, 3 deletions
audit/audit.go
with
15 additions
and
3 deletions
audit/audit.go
+
15
−
3
View file @
83f5be4c
...
...
@@ -198,6 +198,17 @@ func GetAllChanges(original interface{}, new interface{}) (map[string]interface{
if
index
:=
strings
.
Index
(
changesJson
,
split
);
index
>
-
1
&&
changesJson
!=
"{"
{
// Prevent reverse traversal
if
index
>
lastOccurrence
{
// Prevent finding nested keys as opposed to our "change" keys
opener
:=
changesJson
[
index
+
len
(
split
)
+
2
:
index
+
len
(
split
)
+
3
]
// Prevent a "base level" key from matching a nested key
baseLevel
:=
false
if
index
>=
1
{
containedBy
:=
changesJson
[
index
-
1
:
index
]
if
levelsDeep
==
0
&&
(
containedBy
==
"{"
||
containedBy
==
"["
)
{
baseLevel
=
true
}
}
if
(
opener
==
"{"
||
opener
==
"["
)
&&
!
baseLevel
{
lastOccurrence
=
index
lastMatched
=
split
levelsDeep
=
sIndex
...
...
@@ -205,6 +216,7 @@ func GetAllChanges(original interface{}, new interface{}) (map[string]interface{
}
}
}
}
// If the "key" is already present, handle it differently
if
lastOccurrence
>
0
{
...
...
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