Commit c79763ee authored by Aleksandr Gumroian's avatar Aleksandr Gumroian
Browse files

Merge branch 'feature/fix-reforis-dependency' into 'master'

Add CopyInput component with Sentinel device token

Closes #14

See merge request !21
parents 134f046d 36bea5f6
Pipeline #99378 passed with stage
in 3 minutes and 14 seconds
......@@ -41,15 +41,13 @@ all:
venv: $(VENV_NAME)/bin/activate
$(VENV_NAME)/bin/activate: setup.py
test -d $(VENV_NAME) || $(PYTHON) -m virtualenv -p $(PYTHON) $(VENV_NAME)
# Some problem in latest version of setuptools during extracting translations.
$(VENV_BIN)/$(PYTHON) -m pip install -U pip setuptools==39.1.0
$(VENV_BIN)/$(PYTHON) -m pip install -e .[devel]
touch $(VENV_NAME)/bin/activate
prepare-env:
which npm || curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
which npm || sudo apt install -y nodejs
which $(PYTHON) || sudo apt install -y $(PYTHON) $(PYTHON)-pip
which npm || curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
which npm || sudo apt-get install -y nodejs
which $(PYTHON) || sudo apt-get install -y $(PYTHON) $(PYTHON)-pip
which virtualenv || sudo $(PYTHON) -m pip install virtualenv
prepare-dev:
cd $(JS_DIR); npm install
......
......@@ -9,7 +9,7 @@
"version": "0.3.2",
"license": "GPL-3.0",
"dependencies": {
"foris": "^5.1.13"
"foris": "^5.4.0"
},
"devDependencies": {
"@babel/cli": "^7.10.4",
......@@ -38,10 +38,16 @@
"webpack-cli": "^3.3.11"
},
"peerDependencies": {
"axios": "^0.21.1",
"immutability-helper": "3.0.1",
"moment": "^2.24.0",
"prop-types": "15.7.2",
"qrcode.react": "^1.0.1",
"react": "16.9.0",
"react-datetime": "^3.1.1",
"react-dom": "16.9.0",
"react-router-dom": "5.1.2"
"react-router-dom": "5.1.2",
"react-uid": "^2.2.0"
}
},
"node_modules/@babel/cli": {
......@@ -6192,15 +6198,15 @@
}
},
"node_modules/foris": {
"version": "5.1.13",
"resolved": "https://registry.npmjs.org/foris/-/foris-5.1.13.tgz",
"integrity": "sha512-JvHZqCIIyigZyksHAVGRTU+XLn/LMQKyq/pv4V+cVCxWmDvjsuioNrjF6Cp0VGfajv8l1thx/85tEhXhMzos8Q==",
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/foris/-/foris-5.4.0.tgz",
"integrity": "sha512-jjr90dPokG3CIVP49I9zdUlzjeXOo52I/mXjz5lJtpEllXTKhN2ZvgPMjpSjSbIQ2dG4exz+Ks6Qibt4aKJVhA==",
"dependencies": {
"axios": "^0.21.1",
"immutability-helper": "3.0.1",
"moment": "^2.24.0",
"qrcode.react": "^0.9.3",
"react-datetime": "^3.0.4",
"qrcode.react": "^1.0.1",
"react-datetime": "^3.1.1",
"react-uid": "^2.2.0"
},
"peerDependencies": {
......@@ -12224,12 +12230,16 @@
"integrity": "sha1-ys6GOG9ZoNuAUPqQ2baw6IoeNk8="
},
"node_modules/qrcode.react": {
"version": "0.9.3",
"resolved": "https://registry.npmjs.org/qrcode.react/-/qrcode.react-0.9.3.tgz",
"integrity": "sha512-gGd30Ez7cmrKxyN2M3nueaNLk/f9J7NDRgaD5fVgxGpPLsYGWMn9UQ+XnDpv95cfszTQTdaf4QGLNMf3xU0hmw==",
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/qrcode.react/-/qrcode.react-1.0.1.tgz",
"integrity": "sha512-8d3Tackk8IRLXTo67Y+c1rpaiXjoz/Dd2HpcMdW//62/x8J1Nbho14Kh8x974t9prsLHN6XqVgcnRiBGFptQmg==",
"dependencies": {
"loose-envify": "^1.4.0",
"prop-types": "^15.6.0",
"qr.js": "0.0.0"
},
"peerDependencies": {
"react": "^15.5.3 || ^16.0.0 || ^17.0.0"
}
},
"node_modules/qs": {
......@@ -12292,11 +12302,15 @@
}
},
"node_modules/react-datetime": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/react-datetime/-/react-datetime-3.0.4.tgz",
"integrity": "sha512-v6MVwCve+DRaLN2f22LTO5TlrPpkUXumPkp1zfrbhaFtSYGl2grZ2JtwJfLxRj/T4ACyePAV4srCR6cMSiQ/Iw==",
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/react-datetime/-/react-datetime-3.1.1.tgz",
"integrity": "sha512-gHCTjAniCcMb6jdXpz+MpVe/uCeaHNDOofg+l41nLlJI3uBLBMV40CQbGB2TCTUpCzGT1mCs4vQzKGMjXO/WWQ==",
"dependencies": {
"prop-types": "^15.5.7"
},
"peerDependencies": {
"moment": "^2.16.0",
"react": "^16.5.0 || ^17.0.0"
}
},
"node_modules/react-dom": {
......@@ -20656,15 +20670,15 @@
"dev": true
},
"foris": {
"version": "5.1.13",
"resolved": "https://registry.npmjs.org/foris/-/foris-5.1.13.tgz",
"integrity": "sha512-JvHZqCIIyigZyksHAVGRTU+XLn/LMQKyq/pv4V+cVCxWmDvjsuioNrjF6Cp0VGfajv8l1thx/85tEhXhMzos8Q==",
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/foris/-/foris-5.4.0.tgz",
"integrity": "sha512-jjr90dPokG3CIVP49I9zdUlzjeXOo52I/mXjz5lJtpEllXTKhN2ZvgPMjpSjSbIQ2dG4exz+Ks6Qibt4aKJVhA==",
"requires": {
"axios": "^0.21.1",
"immutability-helper": "3.0.1",
"moment": "^2.24.0",
"qrcode.react": "^0.9.3",
"react-datetime": "^3.0.4",
"qrcode.react": "^1.0.1",
"react-datetime": "^3.1.1",
"react-uid": "^2.2.0"
}
},
......@@ -25550,10 +25564,11 @@
"integrity": "sha1-ys6GOG9ZoNuAUPqQ2baw6IoeNk8="
},
"qrcode.react": {
"version": "0.9.3",
"resolved": "https://registry.npmjs.org/qrcode.react/-/qrcode.react-0.9.3.tgz",
"integrity": "sha512-gGd30Ez7cmrKxyN2M3nueaNLk/f9J7NDRgaD5fVgxGpPLsYGWMn9UQ+XnDpv95cfszTQTdaf4QGLNMf3xU0hmw==",
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/qrcode.react/-/qrcode.react-1.0.1.tgz",
"integrity": "sha512-8d3Tackk8IRLXTo67Y+c1rpaiXjoz/Dd2HpcMdW//62/x8J1Nbho14Kh8x974t9prsLHN6XqVgcnRiBGFptQmg==",
"requires": {
"loose-envify": "^1.4.0",
"prop-types": "^15.6.0",
"qr.js": "0.0.0"
}
......@@ -25606,9 +25621,9 @@
}
},
"react-datetime": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/react-datetime/-/react-datetime-3.0.4.tgz",
"integrity": "sha512-v6MVwCve+DRaLN2f22LTO5TlrPpkUXumPkp1zfrbhaFtSYGl2grZ2JtwJfLxRj/T4ACyePAV4srCR6cMSiQ/Iw==",
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/react-datetime/-/react-datetime-3.1.1.tgz",
"integrity": "sha512-gHCTjAniCcMb6jdXpz+MpVe/uCeaHNDOofg+l41nLlJI3uBLBMV40CQbGB2TCTUpCzGT1mCs4vQzKGMjXO/WWQ==",
"requires": {
"prop-types": "^15.5.7"
}
......@@ -10,13 +10,19 @@
"description": "",
"main": "./src/app.js",
"dependencies": {
"foris": "^5.1.13"
"foris": "^5.4.0"
},
"peerDependencies": {
"axios": "^0.21.1",
"immutability-helper": "3.0.1",
"moment": "^2.24.0",
"prop-types": "15.7.2",
"qrcode.react": "^1.0.1",
"react": "16.9.0",
"react-datetime": "^3.1.1",
"react-dom": "16.9.0",
"react-router-dom": "5.1.2"
"react-router-dom": "5.1.2",
"react-uid": "^2.2.0"
},
"devDependencies": {
"@babel/cli": "^7.10.4",
......
/*
* Copyright (C) 2021 CZ.NIC z.s.p.o. (https://www.nic.cz/)
* Copyright (C) 2019-2022 CZ.NIC z.s.p.o. (https://www.nic.cz/)
*
* This is free software, licensed under the GNU General Public License v3.
* See /LICENSE for more information.
......@@ -16,34 +16,30 @@ import DisabledIfNotAccepted from "../utils/DisabledIfNotAccepted";
export default function Sentinel() {
// We had to move API call up to pass it to the `postCallback` function
const [sentinelComponentsState, getSentinelComponentsState] = useAPIGet(
API_URLs.state
);
const [sentinelState, getSentinelState] = useAPIGet(API_URLs.state);
useEffect(() => {
getSentinelComponentsState();
}, [getSentinelComponentsState]);
getSentinelState();
}, [getSentinelState]);
const sentinelIntro = _(
"Sentinel is a Turris threat detection and attack prevention system, which provides dynamic firewall and statistics. Here you can set up several Sentinel components which take part in the threat detection subsystem."
);
return (
<>
<h1>{_("Sentinel")}</h1>
<p>
{_(
"Sentinel is a Turris threat detection and attack prevention system which provides dynamic firewall and statistics. Here you can set up several Sentinel components which take part in the threat detection subsystem."
)}
</p>
<SentinelState
apiState={sentinelComponentsState}
states={sentinelComponentsState}
/>
<p>{sentinelIntro}</p>
<div id="sentinel-state" />
<ForisForm
forisConfig={{
endpoint: API_URLs.settings,
}}
postCallback={getSentinelComponentsState}
postCallback={getSentinelState}
prepDataToSubmit={prepDataToSubmit}
validator={validator}
>
<SentinelState sentinelState={sentinelState} />
<DisabledIfNotAccepted>
<SentinelOptions />
</DisabledIfNotAccepted>
......
......@@ -39,8 +39,9 @@ export default function SentinelOptions({ formData, setFormValue, disabled }) {
<>
<h2>{_(`Sentinel Components`)}</h2>
<p>
{_(`You can select specific components that you want \
to enable or disable.`)}
{_(
"You can select specific components that you want to enable or disable."
)}
</p>
<Switch
label={_("Enable Firewall Logs")}
......
......@@ -6,23 +6,15 @@
*/
const HELP_TEXTS = {
fwlogs: _(`Firewall Logs are logs gathered from iptables firewall. If \
enabled, Sentinel use them to monitor packets coming from outside network and \
trying to connect to potentially vulnerable local services. These techniques, \
also known as "port scans" usually try to detect whether specific ports are \
opened on local device. If enabled, Sentinel Firewall Logs gather information \
about origin of such malicious packets and about ports they try to scan on \
local device.`),
minipots: _(`The main purpose of the Sentinel Minipot is to collect \
authentication information from the login attempts. It is possible to \
emulate some of the often attacked services - Telnet, HTTP, FTP, and SMTP. The \
goal is to catch the attacker red-handed when they think they attack a real \
service.`),
survey: _(`Since our team has only limited manpower, we try to primarily \
focus on subjects that really matter. The Turris survey collects information \
about installed packages, used languages, and operating system versions. Based \
on this we are able to identify widely used packages, features and provide \
special support.`),
fwlogs: _(
`Firewall Logs are logs gathered from iptables firewall. If enabled, Sentinel uses them to monitor packets coming from outside network and trying to connect to potentially vulnerable local services. These techniques, also known as "port scans" usually try to detect whether specific ports are opened on local device. If enabled, Sentinel Firewall Logs gather information about origin of such malicious packets and about ports they try to scan on local device.`
),
minipots: _(
"The main purpose of the Sentinel Minipot is to collect authentication information from the login attempts. It is possible to emulate some of the often attacked services - Telnet, HTTP, FTP, and SMTP. The goal is to catch the attacker red-handed when they think they are attacking a real service."
),
survey: _(
"The Turris survey collects information about installed packages, used languages, and operating system versions. Based on this, we can focus on widely used packages and features and provide support."
),
};
export default HELP_TEXTS;
......@@ -6,52 +6,85 @@
*/
import React from "react";
import ReactDOM from "react-dom";
import PropTypes from "prop-types";
import { formFieldsSize, withSpinnerOnSending, withErrorMessage } from "foris";
import {
formFieldsSize,
withSpinnerOnSending,
withErrorMessage,
CopyInput,
} from "foris";
import SentinelProxyStateIcon from "./SentinelProxyStateIcon";
import SentinelStateTable from "./SentinelStateTable";
SentinelState.propTypes = {
apiState: PropTypes.object.isRequired,
states: PropTypes.object.isRequired,
sentinelState: PropTypes.object.isRequired,
};
export default function SentinelState({ apiState, states }) {
return (
export default function SentinelState({ formData, sentinelState }) {
const stateContainer = document.getElementById("sentinel-state");
const deviceToken = formData.token;
return ReactDOM.createPortal(
<div className={formFieldsSize}>
<h2>{_("Sentinel State")}</h2>
{deviceToken && (
<p
dangerouslySetInnerHTML={{
__html: _(
`To view Sentinel data, please visit <a href="https://view.sentinel.turris.cz" target="_blank" rel="noopener noreferer">Sentinel View<sup><i class="fas fa-external-link-alt fa-xs ml-1"></i></sup></a>. There you can also see and filter <a href="https://view.sentinel.turris.cz/api/device/add?token=${deviceToken}" target="_blank" rel="noopener noreferer">data specific for your device<sup><i class="fas fa-external-link-alt fa-xs ml-1"></i></sup></a>.`
),
}}
/>
)}
<StateWithErrorAndSpinner
apiState={apiState.state}
states={states.data}
apiState={sentinelState.state}
states={sentinelState.data}
deviceToken={deviceToken}
/>
</div>
</div>,
stateContainer
);
}
SentinelStateCard.propTypes = {
states: PropTypes.object.isRequired,
deviceToken: PropTypes.string,
};
function SentinelStateCard({ states }) {
function SentinelStateCard({ states, deviceToken }) {
const isDisabled = states.proxy === "disabled";
return (
<div className="row no-gutters justify-content-center">
<div className="col-md-6 d-flex flex-column align-items-center justify-content-center mt-3 mt-md-0">
<SentinelProxyStateIcon
state={states.proxy}
disabled={isDisabled}
/>
<p className="h4 mt-3">Sentinel</p>
</div>
<div className="col-md-6">
<div className="card-body">
<SentinelStateTable states={states} disabled={isDisabled} />
<>
<div className="row no-gutters justify-content-center">
<div className="col-md-6 d-flex flex-column align-items-center justify-content-center mt-3 mt-md-0">
<SentinelProxyStateIcon
state={states.proxy}
disabled={isDisabled}
/>
<p className="h4 mt-3">Sentinel</p>
</div>
<div className="col-md-6">
<div className="card-body">
<SentinelStateTable
states={states}
disabled={isDisabled}
/>
</div>
</div>
</div>
</div>
{deviceToken && (
<CopyInput
label={_("Device token")}
value={deviceToken || ""}
helpText="That token allows you to access statistics from your device on Sentinel View."
readOnly
/>
)}
</>
);
}
......
......@@ -6,156 +6,226 @@ exports[`<Sentinel /> Snapshot of Sentinel 1`] = `
Sentinel
</h1>
<p>
Sentinel is a Turris threat detection and attack prevention system which provides dynamic firewall and statistics. Here you can set up several Sentinel components which take part in the threat detection subsystem.
Sentinel is a Turris threat detection and attack prevention system, which provides dynamic firewall and statistics. Here you can set up several Sentinel components which take part in the threat detection subsystem.
</p>
<div
class="card p-4 col-sm-12 col-lg-12 p-0 mb-4"
id="sentinel-state"
>
<h2>
Sentinel State
</h2>
<div
class="row no-gutters justify-content-center"
class="card p-4 col-sm-12 col-lg-12 p-0 mb-4"
>
<div
class="col-md-6 d-flex flex-column align-items-center justify-content-center mt-3 mt-md-0"
>
<span
class="text-success"
<h2>
Sentinel State
</h2>
<p>
To view Sentinel data, please visit
<a
href="https://view.sentinel.turris.cz"
rel="noopener noreferer"
target="_blank"
>
<i
class="fas fa-database fa-5x mb-1"
title="Status: Running"
/>
</span>
<p
class="h4 mt-3"
Sentinel View
<sup>
<i
class="fas fa-external-link-alt fa-xs ml-1"
/>
</sup>
</a>
. There you can also see and filter
<a
href="https://view.sentinel.turris.cz/api/device/add?token=random_token"
rel="noopener noreferer"
target="_blank"
>
Sentinel
</p>
</div>
data specific for your device
<sup>
<i
class="fas fa-external-link-alt fa-xs ml-1"
/>
</sup>
</a>
.
</p>
<div
class="col-md-6"
class="row no-gutters justify-content-center"
>
<div
class="card-body"
class="col-md-6 d-flex flex-column align-items-center justify-content-center mt-3 mt-md-0"
>
<span
class="text-success"
>
<i
class="fas fa-database fa-5x mb-1"
title="Status: Running"
/>
</span>
<p
class="h4 mt-3"
>
Sentinel
</p>
</div>
<div
class="col-md-6"
>
<div
class="table-responsive"
class="card-body"
>
<table
class="table table-borderless table-hover mb-0"
<div
class="table-responsive"
>
<tbody>
<tr>
<th
scope="row"
>
Sentinel Proxy
</th>
<td>
<span
class="text-success"
<table
class="table table-borderless table-hover mb-0"
>
<tbody>
<tr>
<th
scope="row"
>
<i
class="fas fa-check"
/>
</span>
</td>
<td
class="text-center"
>
<span
class="badge badge-success"
title="Status: Running"
Sentinel Proxy
</th>
<td>
<span
class="text-success"
>
<i
class="fas fa-check"
/>
</span>
</td>
<td
class="text-center"
>
Running
</span>
</td>
</tr>
<tr>
<th
scope="row"
>
Firewall Logs
</th>
<td>
<span
class="text-warning"
<span
class="badge badge-success"
title="Status: Running"
>
Running
</span>
</td>
</tr>
<tr>
<th
scope="row"
>
<i
class="fas fa-exclamation-triangle"
/>
</span>
</td>
<td
class="text-center"
>
<span
class="badge badge-warning"
title="Status: Disabled"
Firewall Logs
</th>
<td>
<span
class="text-warning"
>
<i
class="fas fa-exclamation-triangle"
/>
</span>
</td>
<td
class="text-center"
>
Disabled
</span>
</td>
</tr>
<tr>
<th
scope="row"
>
Minipots
</th>
<td>
<span
class="text-warning"
<span
class="badge badge-warning"
title="Status: Disabled"
>
Disabled
</span>
</td>
</tr>
<tr>
<th
scope="row"
>
<i
class="fas fa-exclamation-triangle"
/>
</span>
</td>
<td
class="text-center"
>
<span
class="badge badge-warning"
title="Status: Disabled"
Minipots
</th>
<td>
<span
class="text-warning"
>
<i