Skip to content

Commit

Permalink
Merge pull request dbarzin#357 from dbarzin/master
Browse files Browse the repository at this point in the history
Rebase
  • Loading branch information
dbarzin authored Apr 29, 2023
2 parents 1b1cf7e + baa3dd0 commit 3ec5fda
Show file tree
Hide file tree
Showing 171 changed files with 13,310 additions and 269 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
.git
docker/data
*Dockerfile
*.md
.dockerignore
.env*
*.sqlite*
nginx.conf
supervisord.conf
37 changes: 37 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: docker

on:
push:
branches:
- "master"

jobs:
docker:
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Test naming
run: echo "ghcr.io/${{ github.repository }}:latest"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64
push: true
tags: |
ghcr.io/${{ github.repository }}:latest
94 changes: 55 additions & 39 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,45 +1,61 @@
# ubuntu / jammy (22.04-LTS)
FROM ubuntu:jammy

ENV DEBIAN_FRONTEND noninteractive

RUN set -x ; \
apt update ; apt upgrade ; \
apt install -y --no-install-recommends \
ssmtp \
mailutils \
php php-zip \
php-curl \
php-mbstring \
php-dom php-ldap \
php-soap \
php-xdebug \
php-mysql \
php-gd \
php-xdebug \
php-mysql \
php-gd \
graphviz \
curl less ca-certificates netcat-traditional ; \
apt-get autoremove --yes ; rm -fr /var/cache/apt

# install composer
RUN set -x ; \
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

WORKDIR /var/www/mercator
FROM php:8.2-fpm-alpine3.16

# apparently you cannot pass both env variables
# and .env file
ENV DB_CONNECTION=sqlite
ENV DB_DATABASE=/var/www/mercator/db.sqlite

# system deps
RUN apk update && apk add curl nano bash ssmtp graphviz ca-certificates sqlite sqlite-dev postgresql12 postgresql12-dev nginx supervisor

# php deps
RUN apk add php8-zip \
php8-curl \
php8-mbstring \
php8-dom php8-ldap \
php8-soap \
php8-xdebug \
php8-mysqli \
php8-sqlite3 \
php8-pgsql \
php8-gd \
php8-xdebug \
php8-gd \
php8-pdo php8-pdo_sqlite php8-pdo_mysql php8-pdo_pgsql \
php8-fileinfo \
php8-simplexml php8-xml php8-xmlreader php8-xmlwriter \
php8-tokenizer \
composer

RUN docker-php-ext-install pgsql pdo_pgsql

# sources
COPY . /var/www/mercator
WORKDIR /var/www/mercator

# the sqlite file must exist
# RUN touch ${DB_DATABASE}


# USER www:www
# RUN set -x ; \
# groupadd www ; \
# useradd -g www -ms /bin/bash www ; \
# chown -R www:www /var/www ; \
# add mercator:www user
RUN addgroup -S www && \
adduser -S mercator -G www && \
chown -R mercator:www /var/www /var/lib/nginx /var/log/nginx

# COPY nginx.conf /etc/nginx/http.d/mercator.conf
# RUN chown -R mercator:www

# install mercator dependancies
RUN set -x ; \
cd /var/www/mercator ; composer install
RUN cp docker/nginx.conf /etc/nginx/http.d/mercator.conf
RUN cp docker/supervisord.conf /etc/supervisord.conf

USER mercator:www

# install mercator deps
RUN composer install

EXPOSE 8000
ENTRYPOINT /var/www/mercator/docker/entrypoint.sh


CMD ["/usr/bin/supervisord"]

# APP_KEY="${APP_KEY:-base64:$(head -c 32 /dev/urandom|base64)}" php artisan serve --host=0.0.0.0 --port=8000
53 changes: 43 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Mercator

Mercator is an Open Source web application to manage the mapping of an information system as described in the [Mapping The Information System Guide](https://www.ssi.gouv.fr/en/guide/mapping-the-information-system/) of the [ANSSI](https://www.ssi.gouv.fr/en/).
Mercator is an Open Source web application to manage the mapping of an information system as described in the [Mapping The Information System Guide](https://www.ssi.gouv.fr/en/guide/mapping-the-information-system/) of the [ANSSI](https://www.ssi.gouv.fr/en/).

[![Latest Release](https://img.shields.io/github/release/dbarzin/mercator.svg?style=flat-square)](https://github.com/dbarzin/mercator/releases/latest)
![License](https://img.shields.io/github/license/dbarzin/mercator.svg?style=flat-square)
Expand All @@ -11,13 +11,14 @@ Read this in other languages: [French](README.fr.md)

## Introduction

Computer attacks occur in a constantly changing environment. To meet these challenges, it is necessary to implement a global approach to risk management within the organization.
Computer attacks occur in a constantly changing environment. To meet these challenges, it is necessary to implement a global approach to risk management within the organization.

The mapping of the Information System allows to have a global view of all the elements which compose the information system to obtain a better readability, and thus a better control.
The mapping of the Information System allows to have a global view of all the elements which compose the information system to obtain a better readability, and thus a better control.

The elaboration of a cartography participates in the protection, the defense and the resilience of the information system. It is an essential tool for the control of its information system and is an obligation for operators of vital importance and is part of a global risk management approach.

## Major functions

- Graphical views of the ecosystem, information system, administration, logical, applications, and physical infrastructure
- Generate information system architecture report
- Draw mapping diagrams
Expand Down Expand Up @@ -48,26 +49,59 @@ Drawing of the cartography

[<img src="public/screenshots/mercator6.png" width="400" height="300">](public/screenshots/mercator6.png) [<img src="public/screenshots/mercator7.png" width="400" height="300">](public/screenshots/mercator7.png)

Explore
Explore

[<img src="public/screenshots/mercator9.png" width="400">](public/screenshots/mercator9.png)

Data model

[<img src="public/screenshots/mercator8.png" width="400">](public/screenshots/mercator8.png)


[<img src="public/screenshots/mercator8.png" width="400">](public/screenshots/mercator8.png)

## Technologies

- PHP, Javascript, Laravel
- Supported databases: MySQL, Postgres, SQLite, SQL Server (see: [Laravel/Databases/introduction](https://laravel.com/docs/master/database#introduction) )
- WebAssembly + Graphviz
- ChartJS

## Installation

- [Installation](https://github.com/dbarzin/mercator/blob/master/INSTALL.md)
- Deployment under [Docker](https://github.com/dbarzin/mercator/blob/master/docker/README.md)
### Manual

See [Installation](https://github.com/dbarzin/mercator/blob/master/INSTALL.md)

### Docker

First download the docker image.

```shell
docker pull ghcr.io/dbarzin/mercator:latest
```

Then you can run an ephemeral local instance:

```shell
docker run -it --rm --name mercator -p "127.0.0.1:8000":80 ghcr.io/dbarzin/mercator:latest
```

By default it uses an SQLite backend. If you want to make data persistent:

```shell
touch db.sqlite && chmod a+w db.sqlite
docker run -it --rm --name mercator -p "127.0.0.1:8000":80 -v db.sqlite:/var/www/mercator/db.sqlite ghcr.io/dbarzin/mercator:latest
```

Finally you can populate the database with demo data through the `USE_DEMO_DATA` environment variable:

```shell
touch db.sqlite && chmod a+w db.sqlite
docker run -it --rm \
--name mercator \
-p "127.0.0.1:8000":80 \
-v db.sqlite:/var/www/mercator/db.sqlite \
-e USE_DEMO_DATA=1 \
ghcr.io/dbarzin/mercator:latest
```

## Changelog

Expand All @@ -76,4 +110,3 @@ All notable changes to this project are [documented](https://github.com/dbarzin/
## License

Mercator is an open source software distributed under [GPL](https://www.gnu.org/licenses/licenses.html).

7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"oiv",
"security tool",
"anssi",
"urbanisation"
"urbanisation"
],
"license": "GPL-3.0-or-later",
"require": {
Expand All @@ -27,7 +27,8 @@
"phpoffice/phpspreadsheet": "^1.14",
"phpoffice/phpword": "^0.18.0",
"yajra/laravel-datatables": "^1.5",
"yajra/laravel-datatables-oracle": "^9.11"
"yajra/laravel-datatables-oracle": "^9.11",
"orangehill/iseed": "^3.0.3"
},
"require-dev": {
"barryvdh/laravel-ide-helper": "^2.10",
Expand Down Expand Up @@ -76,4 +77,4 @@
"@php artisan key:generate --ansi"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ public function up()
public function down()
{
Schema::table('activity_operation', function (Blueprint $table) {
$table->dropForeign('activity_id_fk_1472704');
$table->dropForeign('operation_id_fk_1472704');
if (DB::getDriverName() !== 'sqlite') {
$table->dropForeign('activity_id_fk_1472704');
}
if (DB::getDriverName() !== 'sqlite') {
$table->dropForeign('operation_id_fk_1472704');
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ public function up()
public function down()
{
Schema::table('activity_process', function (Blueprint $table) {
$table->dropForeign('activity_id_fk_1627616');
$table->dropForeign('process_id_fk_1627616');
if (DB::getDriverName() !== 'sqlite') {
$table->dropForeign('activity_id_fk_1627616');
}
if (DB::getDriverName() !== 'sqlite') {
$table->dropForeign('process_id_fk_1627616');
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ public function up()
public function down()
{
Schema::table('actor_operation', function (Blueprint $table) {
$table->dropForeign('actor_id_fk_1472680');
$table->dropForeign('operation_id_fk_1472680');
if (DB::getDriverName() !== 'sqlite') {
$table->dropForeign('actor_id_fk_1472680');
}
if (DB::getDriverName() !== 'sqlite') {
$table->dropForeign('operation_id_fk_1472680');
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public function up()
public function down()
{
Schema::table('annuaires', function (Blueprint $table) {
$table->dropForeign('zone_admin_fk_1482666');
if (DB::getDriverName() !== 'sqlite') {
$table->dropForeign('zone_admin_fk_1482666');
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ public function up()
public function down()
{
Schema::table('application_module_application_service', function (Blueprint $table) {
$table->dropForeign('application_module_id_fk_1492414');
$table->dropForeign('application_service_id_fk_1492414');
if (DB::getDriverName() !== 'sqlite') {
$table->dropForeign('application_module_id_fk_1492414');
}
if (DB::getDriverName() !== 'sqlite') {
$table->dropForeign('application_service_id_fk_1492414');
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ public function up()
public function down()
{
Schema::table('application_service_m_application', function (Blueprint $table) {
$table->dropForeign('application_service_id_fk_1482585');
$table->dropForeign('m_application_id_fk_1482585');
if (DB::getDriverName() !== 'sqlite') {
$table->dropForeign('application_service_id_fk_1482585');
}
if (DB::getDriverName() !== 'sqlite') {
$table->dropForeign('m_application_id_fk_1482585');
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ public function up()
public function down()
{
Schema::table('bay_wifi_terminal', function (Blueprint $table) {
$table->dropForeign('bay_id_fk_1485509');
$table->dropForeign('wifi_terminal_id_fk_1485509');
if (DB::getDriverName() !== 'sqlite') {
$table->dropForeign('bay_id_fk_1485509');
}
if (DB::getDriverName() !== 'sqlite') {
$table->dropForeign('wifi_terminal_id_fk_1485509');
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public function up()
public function down()
{
Schema::table('bays', function (Blueprint $table) {
$table->dropForeign('room_fk_1483441');
if (DB::getDriverName() !== 'sqlite') {
$table->dropForeign('room_fk_1483441');
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public function up()
public function down()
{
Schema::table('buildings', function (Blueprint $table) {
$table->dropForeign('site_fk_1483431');
if (DB::getDriverName() !== 'sqlite') {
$table->dropForeign('site_fk_1483431');
}
});
}
}
Loading

0 comments on commit 3ec5fda

Please sign in to comment.