Skip to content

Commit

Permalink
Merge branch '1.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Lewis committed Mar 12, 2020
2 parents 5813a54 + f280769 commit 6cbe8ce
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
8 changes: 4 additions & 4 deletions cloud/src/rasp-cloud/controllers/agent/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ func (o *DependencyController) Post() {
dependencies := make([]*models.Dependency, 0, len(param.Dependency))
for _, item := range param.Dependency {
if isValid, errMsg := o.checkDependencyParamItem(item); !isValid {
if conf.AppConfig.DebugModeEnable {
if len(strings.Split(strings.ToLower(errMsg), "empty")) > 1 {
continue
}
if !conf.AppConfig.DebugModeEnable {
if len(strings.Split(strings.ToLower(errMsg), "empty")) > 1 {
continue
}
}
beego.Error("failed to add dependency for rasp: "+rasp.Id, errMsg)
continue
Expand Down
36 changes: 28 additions & 8 deletions cloud/src/rasp-cloud/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ var (
LogPath = "logs/"
PidFileName = LogPath + "pid.file"
OldPid = ""
Status string
)

func init() {
Expand Down Expand Up @@ -133,10 +134,7 @@ func restart() {
}
restartCnt := 0
for {
exist, err := processExists(OldPid)
if err != nil {
log.Fatalln(err)
}
exist := CheckPIDAlreadyRunning(PidFileName)
if !exist {
break
}
Expand Down Expand Up @@ -260,11 +258,15 @@ func HandleDaemon() {
}
time.Sleep(1 * time.Second)
}

if cnt == 29 {
log.Fatal("start timeout! for details please check the log in 'logs/api/agent-cloud.log'")
} else {
} else if CheckPort(port) {
log.Println("start successfully, for details please check the log in 'logs/api/agent-cloud.log'")
} else {
log.Fatal("fail to start! for details please check the log in 'logs/api/agent-cloud.log'")
}

}
os.Exit(0)
}
Expand Down Expand Up @@ -323,17 +325,35 @@ func initEnvConf() {
}

func processExists(pid string) (bool, error) {
if _, err := os.Stat(filepath.Join("/proc", pid)); err == nil {
var err error
if _, err = os.Stat(filepath.Join("/proc", pid)); err == nil {
port := beego.AppConfig.DefaultInt("httpport", 8080)
lsof := exec.Command("/bin/bash", "-c", "lsof -i tcp:"+strconv.Itoa(port))
lsof := exec.Command("/bin/bash", "-c", "lsof -i tcp:" + strconv.Itoa(port))
out, _ := lsof.Output()
if strings.Index(string(out), "rasp-") != -1 {
return true, nil
} else {
return false, nil
}
} else {
//port := beego.AppConfig.DefaultInt("httpport", 8080)
//cmd := "lsof -i tcp:"+strconv.Itoa(port) + "| tail -1"
cmd := "ps -ef|grep " + pid + "|grep -v grep"
lsof := exec.Command("/bin/bash", "-c", cmd)
out, _ := lsof.Output()
if outStr := strings.TrimSpace(string(out)); strings.Index(outStr, "rasp-") != -1 {
if strings.Index(outStr, pid) != -1 {
Status = "restart"
return true, nil
} else if len(outStr) > 0 {
if Status == "restart" {
log.Println(outStr)
}
return false, nil
}
}
}
return false, nil
return false, err
}

func checkPIDAlreadyExists(path string, remove bool) bool {
Expand Down
2 changes: 1 addition & 1 deletion rasp-vue/src/components/pages/settings/whitelist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

<b-modal id="whitelistEditModal" ref="modal" no-fade title="添加/编辑 白名单" size="lg" hide-header-close @hidden="hideModal()" @shown="$refs.focus.focus()">
<div class="form-group">
<label>URL - 不区分 http/https,格式如 <span class="text-danger">rasp.baidu.com/phpmyadmin/</span>;若要匹配全部URL,请写 <strong>*</strong></label>
<label>URL前缀 - 不区分 http/https,不支持通配符或者正则,格式如 <span class="text-danger">rasp.baidu.com/phpmyadmin/</span>;若要匹配全部URL,请写 <strong>*</strong></label>
<input ref="focus" v-model.trim="modalData.url" maxlength="200" type="text" class="form-control" maxlen="200">
</div>
<div class="form-group">
Expand Down

0 comments on commit 6cbe8ce

Please sign in to comment.