mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-27 20:29:39 +02:00
refactor(dynamic): add recursive dependency resolution for Java, Go, and Ruby receivers, expand corresponding tests
This commit is contained in:
parent
0e8c900078
commit
acec041676
10 changed files with 366 additions and 10 deletions
|
|
@ -0,0 +1,32 @@
|
|||
// Benign control for recursively populated Go struct dependencies.
|
||||
package entry
|
||||
|
||||
import "strings"
|
||||
|
||||
type ShellRunner struct{}
|
||||
|
||||
func (ShellRunner) Run(command string) string {
|
||||
return strings.ReplaceAll(command, "NYX_PWN_CMDI", "")
|
||||
}
|
||||
|
||||
type UserRepository struct {
|
||||
Runner *ShellRunner
|
||||
}
|
||||
|
||||
func (r UserRepository) Find(input string) string {
|
||||
if r.Runner == nil {
|
||||
return ""
|
||||
}
|
||||
return r.Runner.Run(input)
|
||||
}
|
||||
|
||||
type UserService struct {
|
||||
Repository *UserRepository
|
||||
}
|
||||
|
||||
func (s UserService) Run(input string) string {
|
||||
if s.Repository == nil {
|
||||
return ""
|
||||
}
|
||||
return s.Repository.Find(input)
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
// Class-method fixture with recursively populated Go struct dependencies.
|
||||
package entry
|
||||
|
||||
import "os/exec"
|
||||
|
||||
type ShellRunner struct{}
|
||||
|
||||
func (ShellRunner) Run(command string) string {
|
||||
out, _ := exec.Command("sh", "-c", "true "+command).Output()
|
||||
return string(out)
|
||||
}
|
||||
|
||||
type UserRepository struct {
|
||||
Runner *ShellRunner
|
||||
}
|
||||
|
||||
func (r UserRepository) Find(input string) string {
|
||||
if r.Runner == nil {
|
||||
return ""
|
||||
}
|
||||
return r.Runner.Run(input)
|
||||
}
|
||||
|
||||
type UserService struct {
|
||||
Repository *UserRepository
|
||||
}
|
||||
|
||||
func (s UserService) Run(input string) string {
|
||||
if s.Repository == nil {
|
||||
return ""
|
||||
}
|
||||
return s.Repository.Find(input)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue