Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
goSDN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
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
Terraform modules
Analyze
Contributor 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
danet
goSDN
Merge requests
!95
path traversal library
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
path traversal library
67-1-path-traversal-get-all
into
67-overhaul-architecture
Overview
0
Commits
5
Pipelines
8
Changes
7
Merged
Ghost User
requested to merge
67-1-path-traversal-get-all
into
67-overhaul-architecture
4 years ago
Overview
0
Commits
5
Pipelines
8
Changes
7
Expand
PathTraversal mechanism isolated as library
Edited
4 years ago
by
Ghost User
0
0
Merge request reports
Compare
67-overhaul-architecture
version 3
f05ecfad
4 years ago
version 2
3bccf682
4 years ago
version 1
8a11ab6e
4 years ago
67-overhaul-architecture (base)
and
latest version
latest version
6cfff6f6
5 commits,
4 years ago
version 3
f05ecfad
4 commits,
4 years ago
version 2
3bccf682
3 commits,
4 years ago
version 1
8a11ab6e
1 commit,
4 years ago
7 files
+
157
−
57
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
7
Search (e.g. *.vue) (Ctrl+P)
cmd/path-traversal/path_traversal.go
+
12
−
53
Options
package
main
import
(
schema
"code.fbi.h-da.de/cocsn/
yang-models/generated/arista
"
"
fmt
"
"github.com/
openconfig/goyang/pkg/yang
"
"code.fbi.h-da.de/cocsn/
gosdn/nucleus/util
"
"
code.fbi.h-da.de/cocsn/yang-models/generated/arista
"
log
"github.com/
sirupsen/logrus
"
)
type
PathElement
struct
{
Children
[]
*
PathElement
Name
string
}
func
(
p
*
PathElement
)
Print
()
{
printPE
(
0
,
p
)
}
func
printPE
(
indent
int
,
pe
*
PathElement
)
{
for
i
:=
0
;
i
<
indent
;
i
++
{
fmt
.
Print
(
" "
)
}
fmt
.
Println
(
pe
.
Name
)
if
len
(
pe
.
Children
)
>
0
{
for
_
,
p
:=
range
pe
.
Children
{
printPE
(
indent
+
1
,
p
)
}
}
}
func
main
()
{
tree
:=
schema
.
SchemaTree
paths
:=
make
(
map
[
string
]
*
PathElement
)
log
.
SetLevel
(
log
.
DebugLevel
)
schema
,
_
:=
arista
.
Schema
()
paths
:=
util
.
NewPaths
()
paths
.
ParseSchema
(
schema
,
"device"
)
for
k
,
v
:=
range
tree
{
if
v
.
Parent
!=
nil
{
if
v
.
Parent
.
Name
==
"device"
{
pathElement
:=
processEntry
(
v
)
pathElement
.
Print
()
paths
[
k
]
=
pathElement
}
}
for
_
,
v
:=
range
paths
{
v
.
Print
()
}
}
func
processEntry
(
e
*
yang
.
Entry
)
*
PathElement
{
if
e
.
Dir
!=
nil
{
elem
:=
&
PathElement
{
Children
:
make
([]
*
PathElement
,
len
(
e
.
Dir
)),
Name
:
e
.
Name
,
}
i
:=
0
for
_
,
v
:=
range
e
.
Dir
{
elem
.
Children
[
i
]
=
processEntry
(
v
)
i
++
}
return
elem
}
leaf
:=
&
PathElement
{
Name
:
e
.
Name
,
}
return
leaf
}
\ No newline at end of file
p
:=
paths
.
StringBuilder
()
log
.
Debug
(
p
)
}
Loading