Skip to content

Commit

Permalink
Merge pull request #36 from Security-Onion-Solutions/kilo
Browse files Browse the repository at this point in the history
Fix change password flow due to Kratos upgrade; Ensure legacy PCAP jobs can be deleted.
  • Loading branch information
jertel authored Jun 18, 2021
2 parents 1652467 + 6966627 commit 41f0f24
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 14 deletions.
18 changes: 8 additions & 10 deletions Dockerfile.kratos
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ RUN addgroup -S ory; \
adduser -S ory -G ory -D -H -s /bin/nologin
RUN apk -U --no-cache add build-base git gcc bash

RUN mkdir -p /go/src/github.com/ory
WORKDIR /go/src/github.com/ory
RUN git clone https://github.com/ory/kratos.git
RUN mkdir -p /go/src/github.com/jertel
WORKDIR /go/src/github.com/jertel
RUN git clone https://github.com/jertel/kratos.git

WORKDIR /go/src/github.com/ory/kratos
WORKDIR /go/src/github.com/jertel/kratos

RUN git checkout v0.6.3-alpha.1
RUN git checkout v0.6.3-alpha.1-so

ENV GO111MODULE on
ENV CGO_ENABLED 1
Expand All @@ -31,8 +31,6 @@ RUN go build -tags sqlite -a
FROM ghcr.io/security-onion-solutions/alpine:latest

ENV DSN=sqlite:///kratos-data/db.sqlite?_fk=true
ENV SQA_OPT_OUT=true
ENV DISABLE_TELEMETRY=true

ARG UID=928
ARG GID=928
Expand All @@ -47,11 +45,11 @@ RUN echo "#!/bin/sh" > /start-kratos.sh
RUN echo "kratos -c /kratos-conf/kratos.yaml migrate sql -e --yes >> /kratos-log/kratos-migrate.log 2>&1" >> /start-kratos.sh
RUN echo "chown kratos:kratos /kratos-data/db.sqlite" >> /start-kratos.sh
RUN echo "chmod 600 /kratos-data/db.sqlite" >> /start-kratos.sh
RUN echo "kratos -c /kratos-conf/kratos.yaml serve >> /kratos-log/kratos.log 2>&1" >> /start-kratos.sh
RUN echo "kratos -c /kratos-conf/kratos.yaml serve --sqa-opt-out=true >> /kratos-log/kratos.log 2>&1" >> /start-kratos.sh
RUN chmod a+x /start-kratos.sh

COPY --from=builder /go/src/github.com/ory/kratos/kratos /usr/bin/kratos
COPY --from=builder /go/src/github.com/ory/kratos/.schema /.schema
COPY --from=builder /go/src/github.com/jertel/kratos/kratos /usr/bin/kratos
COPY --from=builder /go/src/github.com/jertel/kratos/.schema /.schema
USER kratos


Expand Down
11 changes: 7 additions & 4 deletions html/js/routes/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ routes.push({ path: '/settings', name: 'settings', component: {
this.form.csrfToken = response.data.ui.nodes.find(item => item.attributes && item.attributes.name == 'csrf_token').attributes.value;
this.form.method = "password";
var errors = [];
if (response.data.ui.messages) {
const error = response.data.ui.messages.find(item => item.type == "error");
if (error && error.text) {
errors.push(error.text);
if (response.data.ui.nodes) {
const item = response.data.ui.nodes.find(item => item.messages);
if (item) {
const error = item.messages.find(item => item.type == "error");
if (error && error.text) {
errors.push(error.text);
}
}
}
if (errors.length > 0) {
Expand Down
6 changes: 6 additions & 0 deletions model/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type Job struct {
FailCount int `json:"failCount"`
Owner string `json:"owner"`
NodeId string `json:"nodeId"`
LegacySensorId string `json:"sensorId"`
FileExtension string `json:"fileExtension"`
Filter *Filter `json:"filter"`
UserId string `json:"userId"`
Expand All @@ -54,6 +55,11 @@ func (job *Job) GetNodeId() string {
// Lower case on the Getter as well since the property could have been
// manipulated directly. Consider json.Unmarshall().
job.NodeId = strings.ToLower(job.NodeId)
if len(job.NodeId) == 0 {
// See if there's a legacy sensor ID
job.LegacySensorId = strings.ToLower(job.LegacySensorId)
return job.LegacySensorId
}
return job.NodeId
}

Expand Down
22 changes: 22 additions & 0 deletions model/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,26 @@ func TestSetNodeId(tester *testing.T) {
if job.NodeId != "testingthis2" {
tester.Errorf("expected lowercased Node ID after getter but got %s", job.NodeId)
}
}

func TestGetLegacyNodeId(tester *testing.T) {
job := NewJob()
if job.GetNodeId() != "" {
tester.Errorf("expected new jobs to have an empty node ID")
}

job.NodeId = "Foo"
if job.GetNodeId() != "foo" {
tester.Errorf("expected foo but got %s", job.GetNodeId())
}

job.LegacySensorId = "Bar"
if job.GetNodeId() != "foo" {
tester.Errorf("expected foo but got %s", job.GetNodeId())
}

job.NodeId = ""
if job.GetNodeId() != "bar" {
tester.Errorf("expected bar but got %s", job.GetNodeId())
}
}

0 comments on commit 41f0f24

Please sign in to comment.