зеркало из https://github.com/mozilla/mig.git
[medium] convertion from uint64 to float64, take two (cuz maybe I forgot a few...)
This commit is contained in:
Родитель
f4238bd346
Коммит
9e9177f3f5
|
@ -81,7 +81,7 @@ ALTER TABLE ONLY commands
|
|||
ADD CONSTRAINT commands_pkey PRIMARY KEY (id);
|
||||
|
||||
CREATE TABLE invagtmodperm (
|
||||
investigatorid bigint NOT NULL,
|
||||
investigatorid numeric NOT NULL,
|
||||
agentid numeric NOT NULL,
|
||||
moduleid numeric NOT NULL,
|
||||
weight integer NOT NULL
|
||||
|
@ -113,7 +113,7 @@ ALTER TABLE ONLY modules
|
|||
|
||||
CREATE TABLE signatures (
|
||||
actionid numeric NOT NULL,
|
||||
investigatorid bigint NOT NULL,
|
||||
investigatorid numeric NOT NULL,
|
||||
pgpsignature character varying(4096) NOT NULL
|
||||
);
|
||||
ALTER TABLE public.signatures OWNER TO migadmin;
|
||||
|
|
|
@ -90,7 +90,7 @@ ALTER TABLE ONLY commands
|
|||
ADD CONSTRAINT commands_pkey PRIMARY KEY (id);
|
||||
|
||||
CREATE TABLE invagtmodperm (
|
||||
investigatorid bigint NOT NULL,
|
||||
investigatorid numeric NOT NULL,
|
||||
agentid numeric NOT NULL,
|
||||
moduleid numeric NOT NULL,
|
||||
weight integer NOT NULL
|
||||
|
@ -122,7 +122,7 @@ ALTER TABLE ONLY modules
|
|||
|
||||
CREATE TABLE signatures (
|
||||
actionid numeric NOT NULL,
|
||||
investigatorid bigint NOT NULL,
|
||||
investigatorid numeric NOT NULL,
|
||||
pgpsignature character varying(4096) NOT NULL
|
||||
);
|
||||
ALTER TABLE public.signatures OWNER TO migadmin;
|
||||
|
|
|
@ -143,7 +143,7 @@ func getHome(respWriter http.ResponseWriter, request *http.Request) {
|
|||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: fmt.Sprintf("%v", e)}.Err()
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%d", opid), Message: fmt.Sprintf("%v", e)})
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%.0f", opid), Message: fmt.Sprintf("%v", e)})
|
||||
respond(500, resource, respWriter, request, opid)
|
||||
}
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: "leaving getHome()"}.Debug()
|
||||
|
@ -245,7 +245,7 @@ func describeCreateAction(respWriter http.ResponseWriter, request *http.Request)
|
|||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: fmt.Sprintf("%v", e)}.Err()
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%d", opid), Message: fmt.Sprintf("%v", e)})
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%.0f", opid), Message: fmt.Sprintf("%v", e)})
|
||||
respond(500, resource, respWriter, request, opid)
|
||||
}
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: "leaving describeCreateAction()"}.Debug()
|
||||
|
@ -273,7 +273,7 @@ func createAction(respWriter http.ResponseWriter, request *http.Request) {
|
|||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, ActionID: action.ID, Desc: fmt.Sprintf("%v", e)}.Err()
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%d", opid), Message: fmt.Sprintf("%v", e)})
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%.0f", opid), Message: fmt.Sprintf("%v", e)})
|
||||
respond(500, resource, respWriter, request, opid)
|
||||
}
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, ActionID: action.ID, Desc: "leaving createAction()"}.Debug()
|
||||
|
@ -346,7 +346,7 @@ func createAction(respWriter http.ResponseWriter, request *http.Request) {
|
|||
ctx.Channels.Log <- mig.Log{OpID: opid, ActionID: action.ID, Desc: "Action written to database"}
|
||||
|
||||
// write action to disk
|
||||
destdir := fmt.Sprintf("%s/%d.json", ctx.Directories.Action.New, action.ID)
|
||||
destdir := fmt.Sprintf("%s/%.0f.json", ctx.Directories.Action.New, action.ID)
|
||||
newAction, err := json.Marshal(action)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -358,8 +358,8 @@ func createAction(respWriter http.ResponseWriter, request *http.Request) {
|
|||
ctx.Channels.Log <- mig.Log{OpID: opid, ActionID: action.ID, Desc: "Action committed to spool"}
|
||||
|
||||
err = resource.AddItem(cljs.Item{
|
||||
Href: fmt.Sprintf("%s/action?actionid=%d", ctx.Server.BaseURL, action.ID),
|
||||
Data: []cljs.Data{{Name: "action ID " + fmt.Sprintf("%d", action.ID), Value: action}},
|
||||
Href: fmt.Sprintf("%s/action?actionid=%.0f", ctx.Server.BaseURL, action.ID),
|
||||
Data: []cljs.Data{{Name: "action ID " + fmt.Sprintf("%.0f", action.ID), Value: action}},
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -375,7 +375,7 @@ func describeCancelAction(respWriter http.ResponseWriter, request *http.Request)
|
|||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: fmt.Sprintf("%v", e)}.Err()
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%d", opid), Message: fmt.Sprintf("%v", e)})
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%.0f", opid), Message: fmt.Sprintf("%v", e)})
|
||||
respond(500, resource, respWriter, request, opid)
|
||||
}
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: "leaving describeCancelAction()"}.Debug()
|
||||
|
@ -400,7 +400,7 @@ func cancelAction(respWriter http.ResponseWriter, request *http.Request) {
|
|||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: fmt.Sprintf("%v", e)}.Err()
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%d", opid), Message: fmt.Sprintf("%v", e)})
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%.0f", opid), Message: fmt.Sprintf("%v", e)})
|
||||
respond(500, resource, respWriter, request, opid)
|
||||
}
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: "leaving cancelAction()"}.Debug()
|
||||
|
@ -417,7 +417,7 @@ func getAction(respWriter http.ResponseWriter, request *http.Request) {
|
|||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: fmt.Sprintf("%v", e)}.Err()
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%d", opid), Message: fmt.Sprintf("%v", e)})
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%.0f", opid), Message: fmt.Sprintf("%v", e)})
|
||||
respond(500, resource, respWriter, request, opid)
|
||||
}
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: "leaving getAction()"}.Debug()
|
||||
|
@ -456,7 +456,7 @@ func getCommand(respWriter http.ResponseWriter, request *http.Request) {
|
|||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: fmt.Sprintf("%v", e)}.Err()
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%d", opid), Message: fmt.Sprintf("%v", e)})
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%.0f", opid), Message: fmt.Sprintf("%v", e)})
|
||||
respond(500, resource, respWriter, request, opid)
|
||||
}
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: "leaving getCommand()"}.Debug()
|
||||
|
@ -474,8 +474,8 @@ func getCommand(respWriter http.ResponseWriter, request *http.Request) {
|
|||
} else {
|
||||
// nothing to search for, return 404
|
||||
resource.SetError(cljs.Error{
|
||||
Code: fmt.Sprintf("%d", opid),
|
||||
Message: fmt.Sprintf("Invalid Command ID '%d'", commandID)})
|
||||
Code: fmt.Sprintf("%.0f", opid),
|
||||
Message: fmt.Sprintf("Invalid Command ID '%.0f'", commandID)})
|
||||
respond(400, resource, respWriter, request, opid)
|
||||
}
|
||||
// store the results in the resource
|
||||
|
@ -495,7 +495,7 @@ func describeCancelCommand(respWriter http.ResponseWriter, request *http.Request
|
|||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: fmt.Sprintf("%v", e)}.Err()
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%d", opid), Message: fmt.Sprintf("%v", e)})
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%.0f", opid), Message: fmt.Sprintf("%v", e)})
|
||||
respond(500, resource, respWriter, request, opid)
|
||||
}
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: "leaving describeCancelCommand()"}.Debug()
|
||||
|
@ -520,7 +520,7 @@ func cancelCommand(respWriter http.ResponseWriter, request *http.Request) {
|
|||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: fmt.Sprintf("%v", e)}.Err()
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%d", opid), Message: fmt.Sprintf("%v", e)})
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%.0f", opid), Message: fmt.Sprintf("%v", e)})
|
||||
respond(500, resource, respWriter, request, opid)
|
||||
}
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: "leaving cancelCommand()"}.Debug()
|
||||
|
@ -535,7 +535,7 @@ func getAgentsDashboard(respWriter http.ResponseWriter, request *http.Request) {
|
|||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: fmt.Sprintf("%v", e)}.Err()
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%d", opid), Message: fmt.Sprintf("%v", e)})
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%.0f", opid), Message: fmt.Sprintf("%v", e)})
|
||||
respond(500, resource, respWriter, request, opid)
|
||||
}
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: "leaving getAgentsDashboard()"}.Debug()
|
||||
|
@ -550,7 +550,7 @@ func getDashboard(respWriter http.ResponseWriter, request *http.Request) {
|
|||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: fmt.Sprintf("%v", e)}.Err()
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%d", opid), Message: fmt.Sprintf("%v", e)})
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%.0f", opid), Message: fmt.Sprintf("%v", e)})
|
||||
respond(500, resource, respWriter, request, opid)
|
||||
}
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: "leaving getDashboard()"}.Debug()
|
||||
|
|
|
@ -82,7 +82,7 @@ func commandsToComplianceItems(commands []mig.Command) (items []ComplianceItem,
|
|||
bitem.Policy.Level = cmd.Action.Threat.Level
|
||||
bitem.Check.Ref = cmd.Action.Threat.Ref
|
||||
bitem.Check.Description = cmd.Action.Name
|
||||
bitem.Link = fmt.Sprintf("%s/command?commandid=%d", ctx.Server.BaseURL, cmd.ID)
|
||||
bitem.Link = fmt.Sprintf("%s/command?commandid=%.0f", ctx.Server.BaseURL, cmd.ID)
|
||||
for i, result := range cmd.Results {
|
||||
buf, err := json.Marshal(result)
|
||||
if err != nil {
|
||||
|
|
|
@ -45,7 +45,7 @@ import (
|
|||
// actionToItem receives an Action and returns an Item
|
||||
// in the Collection+JSON format
|
||||
func actionToItem(a mig.Action, ctx Context) (item cljs.Item, err error) {
|
||||
item.Href = fmt.Sprintf("%s/action?actionid=%d", ctx.Server.BaseURL, a.ID)
|
||||
item.Href = fmt.Sprintf("%s/action?actionid=%.0f", ctx.Server.BaseURL, a.ID)
|
||||
item.Data = []cljs.Data{
|
||||
{Name: "action", Value: a},
|
||||
}
|
||||
|
@ -57,8 +57,8 @@ func actionToItem(a mig.Action, ctx Context) (item cljs.Item, err error) {
|
|||
}
|
||||
for _, cmd := range commands {
|
||||
link := cljs.Link{
|
||||
Rel: fmt.Sprintf("Command ID %d on agent %s", cmd.ID, cmd.Agent.Name),
|
||||
Href: fmt.Sprintf("%s/command?commandid=%d", ctx.Server.BaseURL, cmd.ID),
|
||||
Rel: fmt.Sprintf("Command ID %.0f on agent %s", cmd.ID, cmd.Agent.Name),
|
||||
Href: fmt.Sprintf("%s/command?commandid=%.0f", ctx.Server.BaseURL, cmd.ID),
|
||||
}
|
||||
links = append(links, link)
|
||||
}
|
||||
|
@ -68,11 +68,11 @@ func actionToItem(a mig.Action, ctx Context) (item cljs.Item, err error) {
|
|||
|
||||
// commandToItem receives a command and returns an Item in Collection+JSON
|
||||
func commandToItem(cmd mig.Command) (item cljs.Item, err error) {
|
||||
item.Href = fmt.Sprintf("%s/command?commandid=%d", ctx.Server.BaseURL, cmd.ID)
|
||||
item.Href = fmt.Sprintf("%s/command?commandid=%.0f", ctx.Server.BaseURL, cmd.ID)
|
||||
links := make([]cljs.Link, 0)
|
||||
link := cljs.Link{
|
||||
Rel: "action",
|
||||
Href: fmt.Sprintf("%s/action?actionid=%d", ctx.Server.BaseURL, cmd.Action.ID),
|
||||
Href: fmt.Sprintf("%s/action?actionid=%.0f", ctx.Server.BaseURL, cmd.Action.ID),
|
||||
}
|
||||
links = append(links, link)
|
||||
item.Links = links
|
||||
|
|
|
@ -61,7 +61,7 @@ func search(respWriter http.ResponseWriter, request *http.Request) {
|
|||
Href: loc,
|
||||
Data: []cljs.Data{{Name: "search parameters", Value: p}},
|
||||
})
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%d", opid), Message: fmt.Sprintf("%v", e)})
|
||||
resource.SetError(cljs.Error{Code: fmt.Sprintf("%.0f", opid), Message: fmt.Sprintf("%v", e)})
|
||||
respond(500, resource, respWriter, request, opid)
|
||||
}
|
||||
ctx.Channels.Log <- mig.Log{OpID: opid, Desc: "leaving search()"}.Debug()
|
||||
|
|
|
@ -260,19 +260,19 @@ func ProcessLog(logctx Logging, l Log) (stop bool, err error) {
|
|||
}
|
||||
|
||||
if l.OpID > 0 {
|
||||
logline += fmt.Sprintf("%d ", l.OpID)
|
||||
logline += fmt.Sprintf("%.0f ", l.OpID)
|
||||
} else {
|
||||
logline += "- "
|
||||
}
|
||||
|
||||
if l.ActionID > 0 {
|
||||
logline += fmt.Sprintf("%d ", l.ActionID)
|
||||
logline += fmt.Sprintf("%.0f ", l.ActionID)
|
||||
} else {
|
||||
logline += "- "
|
||||
}
|
||||
|
||||
if l.CommandID > 0 {
|
||||
logline += fmt.Sprintf("%d ", l.CommandID)
|
||||
logline += fmt.Sprintf("%.0f ", l.CommandID)
|
||||
} else {
|
||||
logline += "- "
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ func flyAction(ctx Context, a mig.Action, origin string) (err error) {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
dest := fmt.Sprintf("%s/%d.json", ctx.Directories.Action.InFlight, a.ID)
|
||||
dest := fmt.Sprintf("%s/%.0f.json", ctx.Directories.Action.InFlight, a.ID)
|
||||
err = safeWrite(ctx, dest, jsonA)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -138,13 +138,13 @@ func landAction(ctx Context, a mig.Action) (err error) {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
dest := fmt.Sprintf("%s/%d.json", ctx.Directories.Action.Done, a.ID)
|
||||
dest := fmt.Sprintf("%s/%.0f.json", ctx.Directories.Action.Done, a.ID)
|
||||
err = safeWrite(ctx, dest, jsonA)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// remove the action from its origin
|
||||
origin := fmt.Sprintf("%s/%d.json", ctx.Directories.Action.InFlight, a.ID)
|
||||
origin := fmt.Sprintf("%s/%.0f.json", ctx.Directories.Action.InFlight, a.ID)
|
||||
os.Remove(origin)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -170,7 +170,7 @@ func safeWrite(ctx Context, destination string, data []byte) (err error) {
|
|||
ctx.Channels.Log <- mig.Log{OpID: ctx.OpID, Desc: "leaving safeWrite()"}.Debug()
|
||||
}()
|
||||
// write the file temp dir
|
||||
tmp := fmt.Sprintf("%s/%d", ctx.Directories.Tmp, mig.GenID())
|
||||
tmp := fmt.Sprintf("%s/%.0f", ctx.Directories.Tmp, mig.GenID())
|
||||
err = ioutil.WriteFile(tmp, data, 0640)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
@ -460,7 +460,7 @@ func createCommand(ctx Context, action mig.Action, agent mig.Agent) (cmdid float
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
dest := fmt.Sprintf("%s/%d-%d.json", ctx.Directories.Command.Ready, action.ID, cmdid)
|
||||
dest := fmt.Sprintf("%s/%.0f-%.0f.json", ctx.Directories.Command.Ready, action.ID, cmdid)
|
||||
err = safeWrite(ctx, dest, data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -510,7 +510,7 @@ func sendCommand(cmdPath string, ctx Context) (err error) {
|
|||
}
|
||||
ctx.Channels.Log <- mig.Log{OpID: ctx.OpID, ActionID: cmd.Action.ID, CommandID: cmd.ID, Desc: "command sent to agent queue"}.Debug()
|
||||
// write command to InFlight directory
|
||||
dest := fmt.Sprintf("%s/%d-%d.json", ctx.Directories.Command.InFlight, cmd.Action.ID, cmd.ID)
|
||||
dest := fmt.Sprintf("%s/%.0f-%.0f.json", ctx.Directories.Command.InFlight, cmd.Action.ID, cmd.ID)
|
||||
err = safeWrite(ctx, dest, data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -540,7 +540,7 @@ func recvAgentResults(msg amqp.Delivery, ctx Context) (err error) {
|
|||
}()
|
||||
|
||||
// write to disk Returned directory
|
||||
dest := fmt.Sprintf("%s/%d", ctx.Directories.Command.Returned, mig.GenID())
|
||||
dest := fmt.Sprintf("%s/%.0f", ctx.Directories.Command.Returned, mig.GenID())
|
||||
err = safeWrite(ctx, dest, msg.Body)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -580,13 +580,13 @@ func terminateCommand(cmdPath string, ctx Context) (err error) {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
dest := fmt.Sprintf("%s/%d-%d.json", ctx.Directories.Command.Done, cmd.Action.ID, cmd.ID)
|
||||
dest := fmt.Sprintf("%s/%.0f-%.0f.json", ctx.Directories.Command.Done, cmd.Action.ID, cmd.ID)
|
||||
err = safeWrite(ctx, dest, data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// remove command from inflight dir
|
||||
inflightPath := fmt.Sprintf("%s/%d-%d.json", ctx.Directories.Command.InFlight, cmd.Action.ID, cmd.ID)
|
||||
inflightPath := fmt.Sprintf("%s/%.0f-%.0f.json", ctx.Directories.Command.InFlight, cmd.Action.ID, cmd.ID)
|
||||
os.Remove(inflightPath)
|
||||
// remove command from Returned dir
|
||||
os.Remove(cmdPath)
|
||||
|
@ -647,7 +647,7 @@ func updateAction(cmdPath string, ctx Context) (err error) {
|
|||
panic(err)
|
||||
}
|
||||
// delete Action from ctx.Directories.Action.InFlight
|
||||
actFile := fmt.Sprintf("%d.json", a.ID)
|
||||
actFile := fmt.Sprintf("%.0f.json", a.ID)
|
||||
os.Rename(ctx.Directories.Action.InFlight+"/"+actFile, ctx.Directories.Action.Done+"/"+actFile)
|
||||
} else {
|
||||
// store updated action in database
|
||||
|
|
|
@ -212,7 +212,7 @@ func destroyAgent(agent mig.Agent, ctx Context) (err error) {
|
|||
}
|
||||
|
||||
// write the action to the spool for scheduling
|
||||
dest := fmt.Sprintf("%s/%d.json", ctx.Directories.Action.New, killAction.ID)
|
||||
dest := fmt.Sprintf("%s/%.0f.json", ctx.Directories.Action.New, killAction.ID)
|
||||
err = safeWrite(ctx, dest, jsonAction)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
Загрузка…
Ссылка в новой задаче