Fixed minor bugs with environment parsing

This commit is contained in:
frikky
2021-07-16 14:32:43 +02:00
parent bc5151bd88
commit 78dbdb8f3f
7 changed files with 65 additions and 44 deletions
-6
View File
@@ -13,10 +13,6 @@ ADD ./go-app/go.mod /app
# Required files for code generation # Required files for code generation
ADD ./app_sdk/app_base.py /app_sdk ADD ./app_sdk/app_base.py /app_sdk
ADD ./app_sdk_kali/app_base.py /app_sdk_kali
ADD ./app_sdk_kali/static_baseline.py /app_sdk_kali
ADD ./app_sdk_blackarch/app_base.py /app_sdk_blackarch
ADD ./app_sdk_blackarch/static_baseline.py /app_sdk_blackarch
ADD ./app_gen /app_gen ADD ./app_gen /app_gen
RUN go get -v RUN go get -v
@@ -31,8 +27,6 @@ FROM alpine:3.12
COPY --from=builder /app/ /app COPY --from=builder /app/ /app
COPY --from=builder /app_sdk/ /app_sdk COPY --from=builder /app_sdk/ /app_sdk
COPY --from=builder /app_sdk_kali/ /app_sdk_kali
COPY --from=builder /app_sdk_blackarch/ /app_sdk_blackarch
COPY --from=builder /app_gen/ /app_gen COPY --from=builder /app_gen/ /app_gen
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
+11 -12
View File
@@ -220,19 +220,18 @@ func buildImageMemory(fs billy.Filesystem, tags []string, dockerfileFolder strin
// docker build --build-arg http_proxy=http://my.proxy.url // docker build --build-arg http_proxy=http://my.proxy.url
// Attempt at setting name according to #359: https://github.com/frikky/Shuffle/issues/359 // Attempt at setting name according to #359: https://github.com/frikky/Shuffle/issues/359
labels := map[string]string{} labels := map[string]string{}
target := "" //target := ""
if len(tags) > 0 { //if len(tags) > 0 {
if strings.Contains(tags[0], ":") { // if strings.Contains(tags[0], ":") {
version := strings.Split(tags[0], ":") // version := strings.Split(tags[0], ":")
if len(version) == 2 { // if len(version) == 2 {
target = fmt.Sprintf("shuffle-build-%s", version[1]) // target = fmt.Sprintf("shuffle-build-%s", version[1])
tags = append(tags, target) // tags = append(tags, target)
labels["name"] = target // labels["name"] = target
} // }
} // }
} //}
_ = labels
buildOptions := types.ImageBuildOptions{ buildOptions := types.ImageBuildOptions{
Remove: true, Remove: true,
Tags: tags, Tags: tags,
+2 -2
View File
@@ -2,7 +2,7 @@ module shuffle
go 1.13 go 1.13
replace github.com/frikky/shuffle-shared => ../../../../git/shuffle-shared //replace github.com/frikky/shuffle-shared => ../../../../git/shuffle-shared
//replace github.com/frikky/kin-openapi => ../../../../git/kin-openapi //replace github.com/frikky/kin-openapi => ../../../../git/kin-openapi
@@ -22,7 +22,7 @@ require (
github.com/docker/go-units v0.4.0 // indirect github.com/docker/go-units v0.4.0 // indirect
github.com/elastic/go-elasticsearch/v7 v7.13.1 // indirect github.com/elastic/go-elasticsearch/v7 v7.13.1 // indirect
github.com/frikky/kin-openapi v0.39.0 github.com/frikky/kin-openapi v0.39.0
github.com/frikky/shuffle-shared v0.0.69 github.com/frikky/shuffle-shared v0.0.71
github.com/fsouza/go-dockerclient v1.7.2 github.com/fsouza/go-dockerclient v1.7.2
github.com/ghodss/yaml v1.0.0 github.com/ghodss/yaml v1.0.0
github.com/go-git/go-billy/v5 v5.0.0 github.com/go-git/go-billy/v5 v5.0.0
+5 -5
View File
@@ -5304,8 +5304,8 @@ func migrateDatabase(resp http.ResponseWriter, request *http.Request) {
} }
ctx := context.Background() ctx := context.Background()
es := shuffle.GetEsConfig() //es := shuffle.GetEsConfig()
_, err := shuffle.RunInit(*dbclient, *es, storage.Client{}, gceProject, "onprem", false, "") _, err := shuffle.RunInit(*dbclient, storage.Client{}, gceProject, "onprem", false, "")
if err != nil { if err != nil {
log.Printf("[WARNING] Failed to start migration because of init issues: %s", err) log.Printf("[WARNING] Failed to start migration because of init issues: %s", err)
resp.WriteHeader(401) resp.WriteHeader(401)
@@ -5387,7 +5387,7 @@ func migrateDatabase(resp http.ResponseWriter, request *http.Request) {
envSuccess := 0 envSuccess := 0
hookSuccess := 0 hookSuccess := 0
scheduleSuccess := 0 scheduleSuccess := 0
_, err = shuffle.RunInit(*dbclient, *es, storage.Client{}, gceProject, "onprem", false, "elasticsearch") _, err = shuffle.RunInit(*dbclient, storage.Client{}, gceProject, "onprem", false, "elasticsearch")
for _, item := range orgs { for _, item := range orgs {
err = shuffle.SetOrg(ctx, item, item.Id) err = shuffle.SetOrg(ctx, item, item.Id)
@@ -5668,14 +5668,14 @@ func initHandlers() {
log.Fatalf("[DEBUG] Database client error during init: %s", err) log.Fatalf("[DEBUG] Database client error during init: %s", err)
} }
es := shuffle.GetEsConfig() //es := shuffle.GetEsConfig()
elasticConfig := "elasticsearch" elasticConfig := "elasticsearch"
if strings.ToLower(os.Getenv("SHUFFLE_ELASTIC")) == "false" { if strings.ToLower(os.Getenv("SHUFFLE_ELASTIC")) == "false" {
elasticConfig = "" elasticConfig = ""
} }
for { for {
_, err = shuffle.RunInit(*dbclient, *es, storage.Client{}, gceProject, "onprem", true, elasticConfig) _, err = shuffle.RunInit(*dbclient, storage.Client{}, gceProject, "onprem", true, elasticConfig)
if err != nil { if err != nil {
log.Printf("[ERROR] Error in initial database connection. Retrying in 5 seconds. %s", err) log.Printf("[ERROR] Error in initial database connection. Retrying in 5 seconds. %s", err)
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)
+1 -1
View File
@@ -16,7 +16,7 @@ services:
depends_on: depends_on:
- backend - backend
backend: backend:
#build: ./backend build: ./backend
image: ghcr.io/frikky/shuffle-backend:nightly image: ghcr.io/frikky/shuffle-backend:nightly
container_name: shuffle-backend container_name: shuffle-backend
hostname: ${BACKEND_HOSTNAME} hostname: ${BACKEND_HOSTNAME}
+44 -17
View File
@@ -559,19 +559,19 @@ const Admin = (props) => {
} }
// Horrible frontend fix for environments // Horrible frontend fix for environments
const setDefaultEnvironment = (name) => { const setDefaultEnvironment = (environment) => {
// FIXME - add some check here ROFL // FIXME - add more checks to this
alert.info("Setting default env to " + name) alert.info("Setting default env to " + environment.name)
var newEnv = [] var newEnv = []
for (var key in environments) { for (var key in environments) {
if (environments[key].Name == name) { if (environments[key].id == environment.id) {
if (environments[key].archived) { if (environments[key].archived) {
alert.error("Can't set archived to default") alert.error("Can't set archived to default")
return return
} }
environments[key].default = true environments[key].default = true
} else if (environments[key].default == true && environments[key].name !== name) { } else if (environments[key].default == true && environments[key].id !== environment.id) {
environments[key].default = false environments[key].default = false
} }
@@ -592,11 +592,15 @@ const Admin = (props) => {
response.json().then(responseJson => { response.json().then(responseJson => {
if (responseJson["success"] === false) { if (responseJson["success"] === false) {
alert.error(responseJson.reason) alert.error(responseJson.reason)
getEnvironments() setTimeout(() => {
getEnvironments()
}, 1500)
} else { } else {
setLoginInfo("") setLoginInfo("")
setModalOpen(false) setModalOpen(false)
getEnvironments() setTimeout(() => {
getEnvironments()
}, 1500)
} }
}), }),
) )
@@ -632,23 +636,46 @@ const Admin = (props) => {
}) })
} }
const deleteEnvironment = (name) => { const deleteEnvironment = (environment) => {
// FIXME - add some check here ROFL // FIXME - add some check here ROFL
alert.info("Deleting environment " + name) //const name = environment.name
//alert.info("Modifying environment " + name)
//var newEnv = []
//for (var key in environments) {
// if (environments[key].Name == name) {
// if (environments[key].default) {
// alert.error("Can't modify the default environment")
// return
// }
// if (environments[key].type === "cloud" && !environments[key].archived) {
// alert.error("Can't modify cloud environments")
// return
// }
// environments[key].archived = !environments[key].archived
// }
// newEnv.push(environments[key])
//}
const id = environment.id
alert.info("Modifying environment " + environment.name)
var newEnv = [] var newEnv = []
for (var key in environments) { for (var key in environments) {
if (environments[key].Name == name) { if (environments[key].id == id) {
if (environments[key].default) { if (environments[key].default) {
alert.error("Can't delete the default environment") alert.error("Can't modify the default environment")
return return
} }
if (environments[key].type === "cloud") { if (environments[key].type === "cloud" && !environments[key].archived) {
alert.error("Can't delete the cloud environments") alert.error("Can't modify cloud environments")
return return
} }
environments[key].archived = true environments[key].archived = !environments[key].archived
} }
newEnv.push(environments[key]) newEnv.push(environments[key])
@@ -2489,7 +2516,7 @@ const Admin = (props) => {
<div> <div>
<div style={{marginTop: 20, marginBottom: 20,}}> <div style={{marginTop: 20, marginBottom: 20,}}>
<h2 style={{display: "inline",}}>Environments</h2> <h2 style={{display: "inline",}}>Environments</h2>
<span style={{marginLeft: 25}}>Decides what Orborus environment to execute an action in a workflow in.<a target="_blank" href="https://shuffler.io/docs/organizations#environments" style={{textDecoration: "none", color: "#f85a3e"}}>Learn more</a></span> <span style={{marginLeft: 25}}>Decides what Orborus environment to execute an action in a workflow in. <a target="_blank" href="https://shuffler.io/docs/organizations#environments" style={{textDecoration: "none", color: "#f85a3e"}}>Learn more</a></span>
</div> </div>
<Button <Button
style={{}} style={{}}
@@ -2572,13 +2599,13 @@ const Admin = (props) => {
{environment.default ? {environment.default ?
null null
: :
<Button variant="outlined" style={{borderRadius: "0px"}} onClick={() => setDefaultEnvironment(environment.Name)} color="primary">Set default</Button> <Button variant="outlined" style={{borderRadius: "0px"}} onClick={() => setDefaultEnvironment(environment)} color="primary">Set default</Button>
} }
</ListItemText> </ListItemText>
<ListItemText <ListItemText
style={{minWidth: 150, maxWidth: 150, overflow: "hidden"}} style={{minWidth: 150, maxWidth: 150, overflow: "hidden"}}
> >
<Button disabled={environment.archived} variant="outlined" style={{borderRadius: "0px"}} onClick={() => deleteEnvironment(environment.Name)} color="primary">Archive</Button> <Button variant={environment.archived ? "contained" : "outlined"} style={{borderRadius: "0px"}} onClick={() => deleteEnvironment(environment)} color="primary">{environment.archived ? "Activate" : "Disable"}</Button>
{/*<Button disabled={environment.archived} variant="outlined" style={{borderRadius: "0px"}} onClick={() => flushQueue(environment.Name)} color="primary">Flush Queue</Button>*/} {/*<Button disabled={environment.archived} variant="outlined" style={{borderRadius: "0px"}} onClick={() => flushQueue(environment.Name)} color="primary">Flush Queue</Button>*/}
</ListItemText> </ListItemText>
<ListItemText <ListItemText
+2 -1
View File
@@ -6160,8 +6160,9 @@ const AngularWorkflow = (props) => {
> >
{subworkflow.actions.map((action, index) => { {subworkflow.actions.map((action, index) => {
//console.log(action) //console.log(action)
const isParent = getParents(selectedTrigger).find(parent => parent.id === action.id)
return ( return (
<MenuItem key={index} style={{backgroundColor: inputColor, color: getParents(selectedTrigger).find(parent => parent.id === action.id) ? "red" : "white"}} value={action}> <MenuItem disabled={isCloud && isParent} key={index} style={{backgroundColor: inputColor, color: isParent ? "red" : "white"}} value={action}>
{action.label} {action.label}
</MenuItem> </MenuItem>
) )