feat(cloudron): add tirreno package artifacts

- Add CloudronStack/output/CloudronPackages-Artifacts/tirreno/ directory and its contents
- Includes package manifest, Dockerfile, source code, documentation, and build artifacts
- Add tirreno-1761840148.tar.gz as a build artifact
- Add tirreno-cloudron-package-1761841304.tar.gz as the Cloudron package
- Include all necessary files for the tirreno Cloudron package

This adds the complete tirreno Cloudron package artifacts to the repository.
This commit is contained in:
2025-10-30 11:43:06 -05:00
parent 0ce353ea9d
commit 91d52d2de5
1692 changed files with 202851 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
config/config.local.ini
config/local/config.local.ini
ui/node_modules
node_modules/*
public/*
vendor/*
.DS_Store
composer.phar
/.php-cs-fixer.cache
logs/*
!/logs/index.php
assets/logs/*
!/assets/logs/index.php
tmp/*
!/tmp/index.php

View File

@@ -0,0 +1,195 @@
# Do not show directory indexes
Options -Indexes
# Do not use multiviews
Options -MultiViews
# Do follow symbolic links
Options +FollowSymLinks
# Options +SymLinksifOwnerMatch
# Character encoding: serve text/html or text/plain as UTF-8
AddDefaultCharset UTF-8
# -----------------------------------------------------------------------------------------------
# Protect from XSS with Apache headers
# -----------------------------------------------------------------------------------------------
<IfModule mod_headers.c>
# prevent site from being loaded in an iframe on another site
Header always append X-Frame-Options SAMEORIGIN
# To prevent cross site scripting (IE8+ proprietary)
Header set X-XSS-Protection "1; mode=block"
</IfModule>
# -----------------------------------------------------------------------------------------------
# Prevent access to various types of files
#
# Note that some of these rules are duplicated by RewriteRules or other .htaccess files.
# -----------------------------------------------------------------------------------------------
# Block access to inc, info, info.json/php, module/php, sh, sql and composer files
# -----------------------------------------------------------------------------------------------
<FilesMatch "\.(inc|info|info\.(json|php)|module|module\.php|sh|sql)$|^\..*$|composer\.(json|lock)$">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
</IfModule>
</FilesMatch>
# Block bak, conf, dist, ini, log, orig, sh, sql, swo, swp, ~, ...
# -----------------------------------------------------------------------------------------------
<FilesMatch "(^#.*#|\.(bak|conf|dist|in[ci]|log|orig|sh|sql|sw[op])|~)$">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
</IfModule>
</FilesMatch>
DirectoryIndex index.php index.html index.htm
# -----------------------------------------------------------------------------------------------
# Enable Apache mod_rewrite
# -----------------------------------------------------------------------------------------------
<IfModule mod_rewrite.c>
RewriteEngine On
# Optionally set a rewrite base if rewrites are not working properly on your server.
# -----------------------------------------------------------------------------------------------
# In addition, if your site directory starts with a "~" you will most likely have to use this.
# https://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
# For ex.:
# RewriteBase /
# RewriteBase /p/
# RewriteBase /~user/
# To redirect HTTP requests to HTTPS, uncomment these lines:
# -----------------------------------------------------------------------------------------------
# RewriteCond %{HTTPS} !=on
# RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# If using load balancer/AWS or behind proxy, use lines below rather lines before:
# -----------------------------------------------------------------------------------------------
# RewriteCond %{HTTP:X-Forwarded-Proto} =https
# RewriteRule ^ - [env=proto:https]
# RewriteCond %{HTTP:X-Forwarded-Proto} =http
# RewriteRule ^ - [env=proto:http]
<IfModule mod_headers.c>
# Uncomment one of lines below and adjust to enable Strict-Transport-Security (HSTS):
# Header always set Strict-Transport-Security "max-age=31536000;"
# Header always set Strict-Transport-Security "max-age=31536000; includeSubdomains"
# Header always set Strict-Transport-Security "max-age=31536000; preload"
# Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
</IfModule>
# -----------------------------------------------------------------------------------------------
# Access Restrictions
# -----------------------------------------------------------------------------------------------
# Keep http requests out of specific files and directories
# -----------------------------------------------------------------------------------------------
# Prevent all the following rules from blocking images in ui directories
RewriteRule (^|/)ui/images/.+\.(jpg|jpeg|png|gif|webp|svg)$ - [L]
# Prevent all the following rules from blocking css directory
RewriteRule (^|/)ui/css/[^/]+\.css$ - [L]
# Prevent all the following rules from blocking js files
RewriteRule (^|/)ui/js/.+\.(map|css|js)$ - [L,QSA]
# Prevent all the following rules from blocking sensor
RewriteRule (^|/)sensor/(|index\.php)$ - [L,QSA]
# Prevent all the following rules from blocking installer
RewriteRule (^|/)install/(|index\.php)$ - [L,QSA]
RewriteRule (^|/)(|index\.php)$ index.php [L,QSA]
# Block access to any htaccess files
RewriteCond %{REQUEST_URI} (^|/)(\.htaccess|htaccess\..*)$ [NC,OR]
# Block access to assets directory
RewriteCond %{REQUEST_URI} (^|/)assets($|/.*$) [NC,OR]
# Block access to the /app directories
RewriteCond %{REQUEST_URI} (^|/)app($|/.*$) [NC,OR]
# Block access to the /sensor directories
RewriteCond %{REQUEST_URI} (^|/)sensor($|/.*$) [NC,OR]
# Block access to the /config directories
RewriteCond %{REQUEST_URI} (^|/)config($|/.*$) [NC,OR]
# Block access to the /tmp directories
RewriteCond %{REQUEST_URI} (^|/)tmp($|/.*$) [NC,OR]
# Block access to the /libs directories
RewriteCond %{REQUEST_URI} (^|/)libs($|/.*$) [NC,OR]
# Block access to the /install directories
RewriteCond %{REQUEST_URI} (^|/)install($|/.*$) [NC,OR]
# Block access to the /vendor directories
RewriteCond %{REQUEST_URI} (^|/)vendor($|/.*$) [NC,OR]
# Block access to the /db directories
RewriteCond %{REQUEST_URI} (^|/)db($|/.*$) [NC]
RewriteRule ^.*$ - [F,L]
# Block access throughout to temporary files ending with tilde created by certain editors
RewriteCond %{REQUEST_URI} \.(html?|inc|json|lock|module|php|py|rb|sh|sql|tpl|tmpl|twig)~$ [NC,OR]
# Block access to markdown and other software documents
RewriteCond %{REQUEST_URI} (^|/)(COPYRIGHT|INSTALL|README|CHANGELOG|LICENSE|AUTHORS|CODE_OF_CONDUCT|LEGALNOTICE|RELEASE_NOTES|SECURITY|FILE_ID|htaccess)(|\.txt|\.md|\.textile|\.diz|\.DIZ)$ [NC,OR]
# Block access to source code files
RewriteCond %{REQUEST_URI} (^|/).+\.(sh|php|txt|yml|conf|ini|log|sql|json|js|md|sh|xml|lock)$ [NC,OR]
# Block access to hidden files
RewriteCond %{REQUEST_URI} (^|/)\..+$ [NC,OR]
# Block access to names of potential backup file extensions within wire or site directories
RewriteCond %{REQUEST_URI} (^|/).+\.(bak|old|sql|sw[op]|(bak|php|sql)[./]+.*)[\d.]*$ [NC,OR]
# Block access to docker files if any left
RewriteCond %{REQUEST_URI} (^|/)(docker|Docker).*[\d.]*$ [NC,OR]
# Block archive file types commonly used for backups
# -----------------------------------------------------------------------------------------------
# This blocks requests for zip, rar, tar, gz, and tgz files that are sometimes left on servers
RewriteCond %{REQUEST_URI} \.(zip|rar|tar|gz|tgz)$ [NC]
RewriteRule ^.*$ - [F,L]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !(favicon\.ico|robots\.txt)
# -----------------------------------------------------------------------------------------------
# Pass control to tirreno if all the above directives allow us to this point.
# For regular VirtualHosts (most installs)
# -----------------------------------------------------------------------------------------------
RewriteRule .* index.php [L,QSA]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
</IfModule>

View File

@@ -0,0 +1,8 @@
chmod 740 composer.json
chmod 740 composer.lock
chmod -R 755 tmp
chmod -R 740 config
chmod -R 755 assets
chmod -R 755 assets/rules
chmod -R 755 assets/logs
chmod -R 755 assets/lists

View File

@@ -0,0 +1,3 @@
# Authors
- Tirreno Technologies Sàrl

View File

@@ -0,0 +1,100 @@
# tirreno changelog
## tirreno v0.9.9
* user activity sparklines charts
* sessions stat collection
* settings for `LOGBOOK_LIMIT`
* settings for `ALLOW_FORGOT_PASSWORD`
* unique UA on language change
* suspicious url substrings update
* textarea url/query rendering fixes
* default current time on invalid eventTime in sensor and 0 on invalid httpCode
* default N/A on empty userName
* jquery-autocomplete update
* minor bug fixes
## tirreno v0.9.8
* field audit trail via new event type `field_edit`
* optional payload for event types `page_search` and `account_email_change`
* sequential load of inner pages elements
* inactive rules visualisation
* extended list for user-agent vulnerability check
* several rules tuning
* Fat-Free Framework update
* minor bug fixes
## tirreno v0.9.7
* DataTables 2.3.2
* different type for event bars charts
* live clock
* new `page_error` event type
* chart for logbook page
* save server time zone timestamp for logbook instead of UTC
* /assets dir for logs, custom rules and suspicious words lists
* prevent parallel requests on daterange switch and rule play
* use only DOM API instead of innerHTML
* improved counties grid and map queries
* fix timestamps localization in panels
* enhanced .htaccess
## tirreno v0.9.6
* flexible rule system
* heroku automated deployment
* improved main page load
* sorting columns whitelists for prevention of ajax blind sql injections
* blacklist chart improvements + chart class reorganization
* add `B23` and `B24` rules
* device detector updates
* /config/local dir for custom configs and extensions
## tirreno v0.9.5
* new search filters for blacklist and users
* review queue and automated blacklisting thresholds
* device detector update
* database updates module
* improved notifications
* default 1D range for grids
* blacklist API
## tirreno v0.9.4
* new search filters for types of events and IPs
* failed login attempt widget for the dashboard screen
* inactive session limit
* new chart for events
* clickable rules
* highlighting reviewed users
* js improvements
* minor bug fixes
* lint configurations
* [wip] review queue threshold settings
## tirreno v0.9.3
* user graph on /event plot
* clickable countries on svg map
* improve /blacklist management
* index.php in all subdirs to prevent directory listing
* force utf-8 sensor input
## tirreno v0.9.2
* XSS vulnerability patch
* optimize getLastEvent()
## tirreno v0.9.1
* data plotting with hour and minute resolution
* minor bug fixes
* dependencies update
* js linting improvements
* logbook search fix
## tirreno v0.9.0
* initial release

View File

@@ -0,0 +1,67 @@
# CONTRIBUTOR COVENANT CODE OF CONDUCT
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our community include:
Demonstrating empathy and kindness toward other people
Being respectful of differing opinions, viewpoints, and experiences
Giving and gracefully accepting constructive feedback
Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
Focusing on what is best not just for us as individuals, but for the overall community
Examples of unacceptable behavior include:
The use of sexualized language or imagery, and sexual attention or advances of any kind
Trolling, insulting or derogatory comments, and personal or political attacks
Public or private harassment
Publishing others private information, such as a physical or email address, without their explicit permission
Other conduct which could reasonably be considered inappropriate in a professional setting
Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at team@tirreno.com. All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
1. Correction
Community Impact: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
Consequence: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
2. Warning
Community Impact: A violation through a single incident or series of actions.
Consequence: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
3. Temporary Ban
Community Impact: A serious violation of community standards, including sustained inappropriate behavior.
Consequence: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
4. Permanent Ban
Community Impact: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
Consequence: A permanent ban from any sort of public interaction within the community.
## Attribution
This Code of Conduct is adapted from the Contributor Covenant, version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html].

View File

@@ -0,0 +1,19 @@
FROM php:8.1-apache
# Install common PHP extensions
RUN docker-php-ext-install mysqli pdo pdo_mysql && docker-php-ext-enable mysqli pdo pdo_mysql
# Enable Apache rewrite module
RUN a2enmod rewrite
# Set working directory to Apache web root
WORKDIR /var/www/html
COPY . .
# Make sure permissions are set correctly
RUN chown -R www-data:www-data /var/www/html
EXPOSE 80
CMD ["apache2-foreground"]

View File

@@ -0,0 +1,60 @@
888
888 888
888
88888888 888 888.d88 888.d88
888 888 888P" 888P"
888 888 888 888
888 888 888 888
888 888 888 888
.d88b. 88.d8b. .d88b.
d8P Y8b 888 "88b d88""88b
88888888 888 888 888 888
Y8b .qq 888 888 888 888
d8bddr 888 888 R88 88P
tirreno - open-source security
platform
888 his is the
8 beginning
8 of a new day.
God has given
me this day to
use as I will.
I can waste it
or use it for good
What I do today
is very important
because I am
exchanging a day
of my life for it.
When tomorrow
comes, this day
will be gone
forever, leaving
something in its
place I have
traded for it
I want it to be
gain, not loss...
Good, not evil...
Success, not failure...
In order that I shall
not forget the
price I paid for it.
*
* *

View File

@@ -0,0 +1,64 @@
JAVASCRIPT AND ADDITIONAL COMPONENTS
accept-language-parser
License: MIT
URL: https://github.com/opentable/accept-language-parser
DataTables
License: MIT
URL: https://datatables.net/
devbridge-jQuery-Autocomplete
License: https://github.com/devbridge/jQuery-Autocomplete/blob/master/license.txt
URL: https://github.com/devbridge/jQuery-Autocomplete
jQuery
License: MIT
URL: https://github.com/jquery/jquery
Tooltipster (tooltipster-master)
License: MIT
URL: https://github.com/calebjacob/tooltipster
uPlot
License: MIT
URL: https://github.com/leeoniya/uPlot
Choices
License: MIT
URL: https://github.com/Choices-js/Choices
jVectorMap
License: AGPL-3.0
URL: https://jvectormap.com/
TinyCode's "Cross My Heart" game
URL: https://github.com/KilledByAPixel/TinyCode/blob/master/games/CrossMyHeart/index256.html
Flag-icons by Lipis
License: MIT
URL: https://github.com/lipis/flag-icons
Icons: Icons used in this project are provided by Streamline (https://streamlinehq.com)
PHP COMPONENTS AND LIBRARIES
Fat-Free Framework
License: GPL v3.0
URL: https://github.com/bcosca/fatfree-core
PHPMailer
License: LGPL v2.1
URL: https://github.com/PHPMailer/PHPMailer
Ruler
License: MIT
URL: https://github.com/bobthecow/Ruler
php-saml by OneLogin
License: MIT
URL: https://github.com/onelogin/php-saml
xmlseclibs by Rob Richards
License: BSD-3-Clause
URL: https://github.com/robrichards/xmlseclibs

View File

@@ -0,0 +1,661 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.

View File

@@ -0,0 +1,126 @@
# tirreno
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/ec30c28f67de476f8b98d2798079bdf0)](https://app.codacy.com/gh/TirrenoTechnologies/tirreno/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![Docker Pulls](https://img.shields.io/docker/pulls/tirreno/tirreno?style=flat)](https://hub.docker.com/r/tirreno/tirreno/)
<p align="center">
<a href="https://www.tirreno.com/" target="_blank">
<img src="https://www.tirreno.com/double-screen.jpg" alt="tirreno screenshot" />
</a>
</p>
The open-source security analytics.
tirreno helps organizations to understand, monitor, and protect their digital platforms from cyber threats, account threats, and abuse. Proactively defend against internal and external threats, ensure sovereignty through on-premises deployment, and secure your digital platforms.
* **Granular visibility**: Understand your application with detailed event tracking and smart monitoring. Capture all events: logins/logouts, data modification, page visits, API calls, along with user context and application errors to get complete operational awareness.
* **Continuous monitoring**: Monitor user behaviour in near real time by choosing from a list of relevant event types. Proactively find cyber threats, account threats, and abuse in your digital platform, and respond to threats quickly based on in-app intelligence.
* **Single user view**: Get comprehensive visibility into individual user activity. Analyze behaviour patterns, risk scores, connected identities, and activity timelines for specific users. Investigate suspicious activity and review detailed session data to make informed security decisions.
* **User risk assessment**: Set up security rules to automatically identify malicious activity, and assess risk tailored to your specific requirements.
* **Case management and auto-decision**: Accounts with risky events are sent to manual review or automatic suspension. Security team can investigate flagged cases and make informed decisions based on comprehensive security analytics.
* **Field audit trail**: Automatically track modifications to important fields, including what changed and when. Centralized field audit trail lets you easily review data changes, streamlining audit and compliance.
* **Enhanced threat intelligence**: tirreno can be enhanced with first-party threat intelligence via API enrichment. Eliminate blind spots and get the threat intelligence you need to build a multi-layered defense for your application. (Optional)
tirreno is a "low-tech" PHP and PostgreSQL software application that can be downloaded and installed on your own web server. After a straightforward five-minute installation process, you can immediately access real-time threat analytics.
## Online demo
Check out the online demo at [play.tirreno.com](https://play.tirreno.com) (admin/tirreno).
## Requirements
* **PHP**: Version 8.0 to 8.3
* **PostgreSQL**: Version 12 or greater
* **PHP extensions**: `PDO_PGSQL`, `cURL`
* **HTTP web server**: `Apache` with `mod_rewrite` and `mod_headers` enabled
* **Operating system**: A Unix-like system is recommended
* **Minimum hardware requirements**:
* **PostgreSQL**: 512 MB RAM (4 GB recommended)
* **Application**: 128 MB RAM (1 GB recommended)
* **Storage**: Approximately 3 GB PostgreSQL storage per 1 million events
## Quickstart install
1. [Download](https://www.tirreno.com/download.php) the latest version of tirreno (ZIP file).
2. Extract the tirreno-master.zip file to the location where you want it installed on your web server.
3. Navigate to `http://your-domain.example/install/index.php` in a browser to launch the installation process.
4. After the successful installation, delete the `install/` directory and its contents.
5. Navigate to `http://your-domain.example/signup/` in a browser to create administrator account.
6. For cron jobs setup insert the following schedule (every 10 minutes) expression with `crontab -e` command or by editing `/var/spool/cron/your-web-server` file:
```
*/10 * * * * cd /path/to/tirreno && /usr/bin/php /path/to/tirreno/index.php /cron >> /path/to/tirreno/assets/logs/error.log 2>&1
```
## Using a docker-based installation (optional)
To run tirreno within docker container you may use image published on [dockerhub](https://hub.docker.com/r/tirreno/tirreno).
```bash
docker pull tirreno/tirreno:latest
```
## Using Heroku (optional)
Click [here](https://heroku.com/deploy?template=https://github.com/tirrenotechnologies/tirreno) to launch heroku deployment.
## Documentation
See the [User Guide](https://docs.tirreno.com/) for details on how to use tirreno.
## Optional non-free capabilities
The open-sourced tirreno code is intended to be used for free as a standalone application. It provides general statistics, rule engine and risk-based alerting to a monitored system. As is, this tooling may be sufficient for bringing insights about user activity and behavioral patterns in a wide range of use cases, especially as a solution for small and medium-sized organizations.
However, if you are looking to cover more advanced usage scenarios, the additional tirreno API enrichment capabilities can be enabled via [monthly-paid subscription](https://www.tirreno.com/pricing/).
## About
The tirreno project started as a proprietary system in 2021 and was open-sourced (AGPL) in December 2024.
Behind tirreno is a blend of extraordinary engineers and professionals, with over a decade of experience in online business operations. We solve real people's challenges through love in ascétique code and sovereign technologies.
tirreno is not VC-motivated. Our inspiration comes from the daily threats posed by organized cybercriminals, driving us to reimagine protection that has never existed before.
The tirreno wordmark stands beyond the horizon line, as a metaphor for the evolutionary cycle of the threat landscape, and our commitment to stay ahead of it.
## Why the name tirreno?
History suggests that the Tyrrhenian people may have lived in Tuscany and eastern Switzerland as far back as 800 BC. The term "Tyrrhenian” became more commonly associated with the Etruscans, and it is from them that the Tyrrhenian Sea derives its name — a name still in use today. This name is believed to be an exonym, possibly meaning “tower”.
While working on the logo, we conducted our own historical study and traced mentions of 'tirreno' back to the 15th-century printed edition of the Vulgate (the Latin Bible). We kept it lowercase to stay true to the original — quite literally, by the book.
The tirreno wordmark, positioned beyond a horizon line, as a metaphor for the constant evolution of the fraud landscape and our commitment to staying ahead of change.
## Links
* [Website](https://www.tirreno.com)
* [Live demo](https://play.tirreno.com)
* [Documentation](https://docs.tirreno.com)
* [Mattermost community](https://chat.tirreno.com)
## Reporting a security issue
If you've found a security-related issue with tirreno, please email security@tirreno.com. Submitting the issue on GitHub exposes the vulnerability to the public, making it easy to exploit. We will publicly disclose the security issue after it has been resolved.
After receiving a report, tirreno will take the following steps:
* Confirm that the report has been received and is being addressed.
* Attempt to reproduce the problem and confirm the vulnerability.
* Release new versions of all the affected packages.
* Announce the problem prominently in the release notes.
* If requested, give credit to the reporter.
## License
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License (AGPL) as published by the Free Software Foundation version 3.
The name "tirreno" is a registered trademark of tirreno technologies sàrl, and tirreno technologies sàrl hereby declines to grant a trademark license to "tirreno" pursuant to the GNU Affero General Public License version 3 Section 7(e), without a separate agreement with tirreno technologies sàrl.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see [GNU Affero General Public License v3](https://www.gnu.org/licenses/agpl-3.0.txt).
## Authors
tirreno Copyright (C) 2025 tirreno technologies sàrl, Vaud, Switzerland. (License AGPLv3)

View File

@@ -0,0 +1,7 @@
Release song: https://youtu.be/nVfTGzlD4_Y
tirreno is announcing version v0.9.9.
This release enhances user visiual analytics, improves user-agent treatment
and introduces several manual app settings, including `.php` formatted lists
of suspicious words.

View File

@@ -0,0 +1,14 @@
# Security Policy
## Reporting a Vulnerability
If you've found a security-related issue with Tirreno, please email security@tirreno.com. Submitting to GitHub makes the vulnerability public, making it easy to exploit. We'll do a public disclosure of the security issue once it's been fixed.
After receiving a report, Tirreno will take the following steps:
- Confirmation that the issue has been received and that it's in the process of being addressed.
- Attempt to reproduce the problem and confirm the vulnerability.
- Create a patch or implement the necessary changes to address the vulnerability.
- Release a new version of all the affected versions.
- Prominently announce the problem in the release notes.
- If requested, give credit to the reporter.

View File

@@ -0,0 +1,47 @@
{
"name": "tirreno",
"description": "Open-source user intelligence platform. Monitor, analyze, and protect your app from cyber and account threats. ",
"website": "https://www.tirreno.com",
"repository": "https://github.com/tirrenotechnologies/tirreno",
"logo": "https://www.tirreno.com/tirreno-logo-public.png",
"keywords": [
"tirreno",
"fraud-detection",
"audit-trail",
"analytics",
"monitoring",
"bot-detection",
"antispam",
"application-monitoring"
],
"success_url": "/install/index.php?mode=schema",
"addons": [
{
"plan": "heroku-postgresql",
"options": {
"version": "14"
}
},
{
"plan": "scheduler"
}
],
"formation": {
"web": {
"quantity": 1,
"size": "basic"
}
},
"buildpacks": [
{
"url": "heroku/php"
}
],
"env": {
"FORCE_HTTPS": {
"description": "Secure HTTP for SITE variable",
"required": true,
"value": "True"
}
}
}

View File

@@ -0,0 +1,14 @@
{
"id": "com.tirrenotechnologies.tirreno.cloudron",
"title": "tirreno",
"version": "1.0.0",
"build": "1",
"description": "Cloudron package for tirreno",
"author": "Auto-generated",
"website": "https://github.com/tirrenotechnologies/tirreno",
"admin": false,
"tags": ["php", "auto-generated"],
"logo": "https://github.com/fluidicon.png",
"documentation": "https://github.com/tirrenotechnologies/tirreno",
"changelog": "Initial packaging"
}

View File

@@ -0,0 +1,19 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Assets;
abstract class Rule extends \Controllers\Admin\Rules\Set\BaseRule {
}

View File

@@ -0,0 +1,3 @@
<?php
//

View File

@@ -0,0 +1,309 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Api;
class Data extends \Controllers\Base {
use \Traits\ApiKeys;
protected $ENRICHED_ATTRIBUTES = [];
public function __construct() {
parent::__construct();
$this->ENRICHED_ATTRIBUTES = array_keys(\Utils\Constants::get('ENRICHING_ATTRIBUTES'));
}
public function proceedPostRequest(array $params): array {
$cmd = $params['cmd'] ?? '';
return match ($cmd) {
'resetKey' => $this->resetApiKey($params),
'updateApiUsage' => $this->updateApiUsage($params),
'enrichAll' => $this->enrichAll($params),
default => []
};
}
public function getUsageStats(int $operatorId): array {
$model = new \Models\ApiKeys();
$apiKeys = $model->getKeys($operatorId);
$isOwner = true;
if (!$apiKeys) {
$coOwnerModel = new \Models\ApiKeyCoOwner();
$coOwnerModel->getCoOwnership($operatorId);
if ($coOwnerModel->loaded()) {
$isOwner = false;
$apiKeys[] = $model->getKeyById($coOwnerModel->api);
}
}
if (!$isOwner) {
return ['data' => []];
}
$resultKeys = [];
foreach ($apiKeys as $key) {
$subscriptionStats = [];
if ($key->token !== null) {
[$code, $response, $error] = $this->getSubscriptionStats($key->token);
$subscriptionStats = strlen($error) > 0 || $code > 201 ? [] : $response;
}
$remaining = $subscriptionStats['remaining'] ?? null;
$total = $subscriptionStats['total'] ?? null;
$used = $remaining !== null && $total !== null ? $total - $remaining : null;
$resultKeys[] = [
'id' => $key->id,
'key' => $key->key,
'apiToken' => $key->token ?? null,
'sub_status' => $subscriptionStats['status'] ?? null,
'sub_calls_left' => $remaining,
'sub_calls_used' => $used,
'sub_calls_limit' => $total,
'sub_next_billed' => $subscriptionStats['next_billed_at'] ?? null,
'sub_update_url' => $subscriptionStats['update_url'] ?? null,
'sub_plan_id' => $subscriptionStats['current_subscription_plan']['sub_id'] ?? null,
'sub_plan_api_calls' => $subscriptionStats['current_subscription_plan']['api_calls'] ?? null,
//'all_subscription_plans' => $subscriptionStats['all_subscription_plans'] ?? null,
];
}
return ['data' => $resultKeys];
}
public function getOperatorApiKeysDetails(int $operatorId): array {
[$isOwner, $apiKeys] = $this->getOperatorApiKeys($operatorId);
$resultKeys = [];
foreach ($apiKeys as $key) {
$resultKeys[] = [
'id' => $key->id,
'key' => $key->key,
'created_at' => $key->created_at,
'skip_enriching_attributes' => $key->skip_enriching_attributes,
'enrichedAttributes' => $this->getEnrichedAttributes($key),
'retention_policy' => $key->retention_policy,
'skip_blacklist_sync' => $key->skip_blacklist_sync,
'apiToken' => $key->token ?? null,
];
}
return [$isOwner, $resultKeys];
}
private function getSubscriptionStats(string $token): array {
$api = \Utils\Variables::getEnrichtmentApi();
$options = [
'method' => 'GET',
'header' => [
'Authorization: Bearer ' . $token,
'User-Agent: ' . $this->f3->get('USER_AGENT'),
],
];
/** @var array{request: array<string>, body: string, headers: array<string>, engine: string, cached: bool, error: string} $result */
$result = \Web::instance()->request(
url: sprintf('%s/usage-stats', $api),
options: $options,
);
$matches = [];
preg_match('/^HTTP\/(\d+)(?:\.\d)? (\d{3})/', $result['headers'][0], $matches);
$statusCode = (int) ($matches[2] ?? 0);
$errorMessage = $result['error'];
$jsonResponse = json_decode($result['body'], true);
return [$statusCode, $jsonResponse, $errorMessage];
}
public function resetApiKey(array $params): array {
$pageParams = [];
$errorCode = $this->validateResetApiKey($params);
if ($errorCode) {
$pageParams['ERROR_CODE'] = $errorCode;
} else {
$keyId = isset($params['keyId']) ? (int) $params['keyId'] : null;
$model = new \Models\ApiKeys();
$model->getKeyById($keyId);
$model->resetKey($keyId, $model->creator);
$pageParams['SUCCESS_MESSAGE'] = $this->f3->get('AdminApi_reset_success_message');
}
return $pageParams;
}
public function enrichAll(array $data): array {
$pageParams = [];
$errorCode = $this->validateEnrichAll($data);
if ($errorCode) {
$pageParams['ERROR_CODE'] = $errorCode;
} else {
$apiKey = $this->getCurrentOperatorApiKeyId();
$model = new \Models\Users();
$accountsForEnrichment = $model->notCheckedUsers($apiKey);
$actionType = new \Type\QueueAccountOperationActionType(\Type\QueueAccountOperationActionType::ENRICHMENT);
$accountOpQueueModel = new \Models\Queue\AccountOperationQueue($actionType);
$accountOpQueueModel->addBatchIds($accountsForEnrichment, $apiKey);
$pageParams['SUCCESS_MESSAGE'] = $this->f3->get('AdminApi_manual_enrichment_success_message');
}
return $pageParams;
}
public function validateEnrichAll(array $params): int|false {
$errorCode = \Utils\Access::CSRFTokenValid($params, $this->f3);
if ($errorCode) {
return $errorCode;
}
return false;
}
public function validateResetApiKey(array $params): int|false {
$errorCode = \Utils\Access::CSRFTokenValid($params, $this->f3);
if ($errorCode) {
return $errorCode;
}
$keyId = isset($params['keyId']) ? (int) $params['keyId'] : null;
if (!$keyId) {
return \Utils\ErrorCodes::API_KEY_ID_DOESNT_EXIST;
}
if ($keyId !== $this->getCurrentOperatorApiKeyId()) {
return \Utils\ErrorCodes::API_KEY_WAS_CREATED_FOR_ANOTHER_USER;
}
return false;
}
private function validateApiKeyAccess(int $keyId, int $operatorId): bool {
$model = new \Models\ApiKeys();
$model->getByKeyAndOperatorId($keyId, $operatorId);
if (!$model->loaded()) {
$coOwnerModel = new \Models\ApiKeyCoOwner();
$coOwnerModel->getCoOwnership($operatorId);
if (!$coOwnerModel->loaded()) {
return false;
}
}
return true;
}
public function getEnrichedAttributes(\Models\ApiKeys $key): array {
$enrichedAttributes = [];
$skipAttributes = \json_decode($key->skip_enriching_attributes);
foreach ($this->ENRICHED_ATTRIBUTES as $attribute) {
$enrichedAttributes[$attribute] = !\in_array($attribute, $skipAttributes);
}
return $enrichedAttributes;
}
public function updateApiUsage(array $params): array {
$errorCode = $this->validateUpdateApiUsage($params);
$pageParams = [];
if ($errorCode) {
$pageParams['ERROR_CODE'] = $errorCode;
} else {
$keyId = isset($params['keyId']) ? (int) $params['keyId'] : null;
$model = new \Models\ApiKeys();
$model->getKeyById($keyId);
if ($params['apiToken'] !== null) {
$apiToken = trim($params['apiToken']);
[$code, , $error] = $this->getSubscriptionStats($apiToken);
if (strlen($error) > 0 || $code > 201) {
$pageParams['ERROR_CODE'] = \Utils\ErrorCodes::SUBSCRIPTION_KEY_INVALID_UPDATE;
return $pageParams;
}
$model->updateInternalToken($apiToken);
}
$enrichedAttributes = $params['enrichedAttributes'] ?? [];
$skipEnrichingAttributes = \array_diff($this->ENRICHED_ATTRIBUTES, \array_keys($enrichedAttributes));
$model->updateSkipEnrichingAttributes($skipEnrichingAttributes);
$skipBlacklistSync = !isset($params['exchangeBlacklist']);
$model->updateSkipBlacklistSynchronisation($skipBlacklistSync);
$pageParams['SUCCESS_MESSAGE'] = $this->f3->get('AdminApi_data_enrichment_success_message');
}
return $pageParams;
}
public function validateUpdateApiUsage(array $params): int|false {
$errorCode = \Utils\Access::CSRFTokenValid($params, $this->f3);
if ($errorCode) {
return $errorCode;
}
$keyId = isset($params['keyId']) ? (int) $params['keyId'] : null;
if (!$keyId) {
return \Utils\ErrorCodes::API_KEY_ID_DOESNT_EXIST;
}
$currentOperator = $this->f3->get('CURRENT_USER');
$operatorId = $currentOperator->id;
if (!$this->validateApiKeyAccess($keyId, $operatorId)) {
return \Utils\ErrorCodes::API_KEY_WAS_CREATED_FOR_ANOTHER_USER;
}
$enrichedAttributes = $params['enrichedAttributes'] ?? [];
$unknownAttributes = \array_diff(\array_keys($enrichedAttributes), $this->ENRICHED_ATTRIBUTES);
if ($unknownAttributes) {
return \Utils\ErrorCodes::UNKNOWN_ENRICHMENT_ATTRIBUTES;
}
return false;
}
public function getNotCheckedEntitiesForLoggedUser(): bool {
$apiKey = $this->getCurrentOperatorApiKeyId();
$controller = new \Controllers\Admin\Enrichment\Data();
return $controller->getNotCheckedExists($apiKey);
}
public function getScheduledForEnrichment(): bool {
$apiKey = $this->getCurrentOperatorApiKeyId();
$actionType = new \Type\QueueAccountOperationActionType(\Type\QueueAccountOperationActionType::ENRICHMENT);
$accountOpQueueModel = new \Models\Queue\AccountOperationQueue($actionType);
// do not use isInQueue() to prevent true on failed state
return $accountOpQueueModel->actionIsInQueueProcessing($apiKey);
}
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Api;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function showIndexPage(): void {
$this->redirectIfUnlogged();
$pageController = new Page();
$this->response = new \Views\Frontend();
$this->response->data = $pageController->getPageParams();
}
public function getUsageStats(): array {
$currentOperator = $this->f3->get('CURRENT_USER');
$operatorId = $currentOperator->id;
return $operatorId ? (new Data())->getUsageStats($operatorId) : [];
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Api;
class Page extends \Controllers\Pages\Base {
use \Traits\ApiKeys;
public $page = 'AdminApi';
public function getPageParams(): array {
$dataController = new Data();
$currentOperator = $this->f3->get('CURRENT_USER');
$operatorId = $currentOperator->id;
$scheduledForEnrichment = $dataController->getScheduledForEnrichment();
$pageParams = [
'LOAD_AUTOCOMPLETE' => true,
'LOAD_DATATABLE' => true,
'HTML_FILE' => 'admin/api.html',
'JS' => 'admin_api.js',
'API_URL' => \Utils\Variables::getSiteWithProtocol() . '/sensor/',
'SCHEDULED_FOR_ENRICHMENT' => $scheduledForEnrichment,
];
if ($this->isPostRequest()) {
$params = $this->f3->get('POST');
$params['id'] = $operatorId;
$operationResponse = $dataController->proceedPostRequest($params);
$pageParams = array_merge($pageParams, $operationResponse);
$pageParams['CMD'] = $params['cmd'] ?? null;
}
// set these params after proccessing POST request
[$isOwner, $apiKeys] = $dataController->getOperatorApiKeysDetails($operatorId);
$pageParams['IS_OWNER'] = $isOwner;
$pageParams['API_KEYS'] = $apiKeys;
$pageParams['NOT_CHECKED'] = $dataController->getNotCheckedEntitiesForLoggedUser();
return parent::applyPageParams($pageParams);
}
}

View File

@@ -0,0 +1,40 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Blacklist;
class Data extends \Controllers\Base {
public function getList(int $apiKey): array {
$model = new \Models\Grid\Blacklist\Grid($apiKey);
return $model->getAllBlacklistedItems();
}
public function removeItemFromBlacklist(int $itemId, string $type, int $apiKey): void {
$model = null;
if ($type === 'ip') {
$model = new \Models\Ip();
}
if ($type === 'email') {
$model = new \Models\Email();
}
if ($type === 'phone') {
$model = new \Models\Phone();
}
$model->updateFraudFlag([$itemId], false, $apiKey);
}
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Blacklist;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function showIndexPage(): void {
$this->redirectIfUnlogged();
$pageController = new Page();
$this->response = new \Views\Frontend();
$this->response->data = $pageController->getPageParams();
}
public function getList(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getList($apiKey) : [];
}
public function removeItemFromList(): array {
$dataController = new Data();
$apiKey = $this->getCurrentOperatorApiKeyId();
$id = $this->f3->get('REQUEST.id');
$type = $this->f3->get('REQUEST.type');
$dataController->removeItemFromBlacklist($id, $type, $apiKey);
$successCode = \Utils\ErrorCodes::ITEM_HAS_BEEN_SUCCESSFULLY_REMOVED_FROM_BLACK_LIST;
return [
'success' => $successCode,
'id' => $id,
];
}
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Blacklist;
class Page extends \Controllers\Pages\Base {
public $page = 'AdminBlacklist';
public function getPageParams(): array {
$searchPlacholder = $this->f3->get('AdminBlacklist_search_placeholder');
$pageParams = [
'SEARCH_PLACEHOLDER' => $searchPlacholder,
'LOAD_UPLOT' => true,
'LOAD_DATATABLE' => true,
'LOAD_CHOICES' => true,
'LOAD_AUTOCOMPLETE' => true,
'HTML_FILE' => 'admin/blacklist.html',
'JS' => 'admin_blacklist.js',
'ENTITY_TYPES' => \Utils\Constants::get('ENTITY_TYPES'),
];
return parent::applyPageParams($pageParams);
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Bot;
class Data extends \Controllers\Base {
use \Traits\ApiKeys;
public function proceedPostRequest(array $params): array {
return match ($params['cmd']) {
'reenrichment' => $this->enrichEntity($params),
default => []
};
}
public function enrichEntity(array $params): array {
$dataController = new \Controllers\Admin\Enrichment\Data();
$apiKey = $this->getCurrentOperatorApiKeyId();
$enrichmentKey = $this->getCurrentOperatorEnrichmentKeyString();
$type = $params['type'];
$search = $params['search'] ?? null;
$entityId = isset($params['entityId']) ? (int) $params['entityId'] : null;
return $dataController->enrichEntity($type, $search, $entityId, $apiKey, $enrichmentKey);
}
public function checkIfOperatorHasAccess(int $botId): bool {
$apiKey = $this->getCurrentOperatorApiKeyId();
$model = new \Models\Bot();
return $model->checkAccess($botId, $apiKey);
}
public function getBotDetails(int $botId): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
$model = new \Models\Bot();
return $model->getFullBotInfoById($botId, $apiKey);
}
public function isEnrichable(): bool {
$apiKey = $this->getCurrentOperatorApiKeyId();
$model = new \Models\ApiKeys();
return $model->attributeIsEnrichable('ua', $apiKey);
}
}

View File

@@ -0,0 +1,40 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Bot;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function showIndexPage(): void {
$this->redirectIfUnlogged();
$pageController = new Page();
$this->response = new \Views\Frontend();
$this->response->data = $pageController->getPageParams();
}
public function getBotDetails(): array {
$dataController = new Data();
$botId = $this->f3->get('REQUEST.botId');
$hasAccess = $dataController->checkIfOperatorHasAccess($botId);
if (!$hasAccess) {
$this->f3->error(404);
}
return $dataController->getBotDetails($botId);
}
}

View File

@@ -0,0 +1,59 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Bot;
class Page extends \Controllers\Pages\Base {
public $page = 'AdminBot';
public function getPageParams(): array {
$dataController = new Data();
$botId = $this->integerParam($this->f3->get('PARAMS.botId'));
$hasAccess = $dataController->checkIfOperatorHasAccess($botId);
if (!$hasAccess) {
$this->f3->error(404);
}
$bot = $dataController->getBotDetails($botId);
$pageTitle = $this->getInternalPageTitleWithPostfix($bot['id']);
$isEnrichable = $dataController->isEnrichable();
$pageParams = [
'LOAD_DATATABLE' => true,
'LOAD_JVECTORMAP' => true,
'LOAD_ACCEPT_LANGUAGE_PARSER' => true,
'LOAD_AUTOCOMPLETE' => true,
'HTML_FILE' => 'admin/bot.html',
'BOT' => $bot,
'PAGE_TITLE' => $pageTitle,
'LOAD_UPLOT' => true,
'JS' => 'admin_bot.js',
'IS_ENRICHABLE' => $isEnrichable,
];
if ($this->isPostRequest()) {
$params = $this->f3->get('POST');
$operationResponse = $dataController->proceedPostRequest($params);
$pageParams = array_merge($pageParams, $operationResponse);
$pageParams['CMD'] = $params['cmd'];
// recall bot data
$pageParams['BOT'] = $dataController->getBotDetails($botId);
}
return parent::applyPageParams($pageParams);
}
}

View File

@@ -0,0 +1,24 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Bots;
class Data extends \Controllers\Base {
public function getList(int $apiKey): array {
$model = new \Models\Grid\Bots\Grid($apiKey);
return $model->getAllBots();
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Bots;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function showIndexPage(): void {
$this->redirectIfUnlogged();
$pageController = new Page();
$this->response = new \Views\Frontend();
$this->response->data = $pageController->getPageParams();
}
public function getList(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getList($apiKey) : [];
}
}

View File

@@ -0,0 +1,36 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Bots;
class Page extends \Controllers\Pages\Base {
public $page = 'AdminBots';
public function getPageParams(): array {
$searchPlacholder = $this->f3->get('AdminBots_search_placeholder');
$pageParams = [
'SEARCH_PLACEHOLDER' => $searchPlacholder,
'LOAD_UPLOT' => true,
'LOAD_DATATABLE' => true,
'LOAD_ACCEPT_LANGUAGE_PARSER' => true,
'LOAD_AUTOCOMPLETE' => true,
'HTML_FILE' => 'admin/bots.html',
'JS' => 'admin_bots.js',
];
return parent::applyPageParams($pageParams);
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Context;
class Data extends \Controllers\Base {
private \Models\Context\Data $model;
public function __construct() {
$this->model = new \Models\Context\Data();
}
public function getContextByAccountIds(array $accountIds, int $apiKey): array {
return $this->getContext($accountIds, $apiKey);
}
public function getContextByAccountId(int $accountId, int $apiKey): array {
$accountIds = [$accountId];
$context = $this->getContext($accountIds, $apiKey);
return $context[$accountId] ?? [];
}
private function getContext(array $accountIds, int $apiKey): array {
return $this->model->getContext($accountIds, $apiKey);
}
}

View File

@@ -0,0 +1,79 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Countries;
class Data extends \Controllers\Base {
public function getList(int $apiKey): array {
$result = [];
$model = new \Models\Grid\Countries\Grid($apiKey);
$result = $model->getAllCountries();
$ids = array_column($result['data'], 'id');
if ($ids) {
$model = new \Models\Country();
$model->updateTotalsByEntityIds($ids, $apiKey);
$result['data'] = $model->refreshTotals($result['data'], $apiKey);
}
return $result;
}
public function getMap(int $apiKey): array {
$result = [];
$model = new \Models\Map();
$ispId = $this->f3->get('REQUEST.ispId');
$userId = $this->f3->get('REQUEST.userId');
$botId = $this->f3->get('REQUEST.botId');
$domainId = $this->f3->get('REQUEST.domainId');
$resourceId = $this->f3->get('REQUEST.resourceId');
if (isset($userId) && is_numeric($userId)) {
$result = $model->getCountriesByUserId($userId, $apiKey);
}
if (isset($ispId) && is_numeric($ispId)) {
$result = $model->getCountriesByIspId($ispId, $apiKey);
}
if (isset($domainId) && is_numeric($domainId)) {
$result = $model->getCountriesByDomainId($domainId, $apiKey);
}
if (isset($botId) && is_numeric($botId)) {
$result = $model->getCountriesByBotId($botId, $apiKey);
}
if (isset($resourceId) && is_numeric($resourceId)) {
$result = $model->getCountriesByResourceId($resourceId, $apiKey);
}
if (!$result) {
$dateFrom = $this->f3->get('REQUEST.dateFrom');
$dateTo = $this->f3->get('REQUEST.dateTo');
$dateFrom = ($dateFrom) ? date('Y-m-d H:i:s', strtotime($dateFrom)) : null;
$dateTo = ($dateTo) ? date('Y-m-d H:i:s', strtotime($dateTo)) : null;
$result = $model->getAllCountries($dateFrom, $dateTo, $apiKey);
}
return $result;
}
}

View File

@@ -0,0 +1,41 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Countries;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function showIndexPage(): void {
$this->redirectIfUnlogged();
$pageController = new Page();
$this->response = new \Views\Frontend();
$this->response->data = $pageController->getPageParams();
}
public function getList(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getList($apiKey) : [];
}
public function getMap(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getMap($apiKey) : [];
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Countries;
class Page extends \Controllers\Pages\Base {
public $page = 'AdminCountries';
public function getPageParams(): array {
$searchPlacholder = $this->f3->get('AdminCountries_search_placeholder');
$pageParams = [
'SEARCH_PLACEHOLDER' => $searchPlacholder,
'LOAD_JVECTORMAP' => true,
'LOAD_DATATABLE' => true,
'LOAD_AUTOCOMPLETE' => true,
'HTML_FILE' => 'admin/countries.html',
'JS' => 'admin_countries.js',
];
return parent::applyPageParams($pageParams);
}
}

View File

@@ -0,0 +1,34 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Country;
class Data extends \Controllers\Base {
use \Traits\ApiKeys;
public function checkIfOperatorHasAccess(int $countryId): bool {
$apiKey = $this->getCurrentOperatorApiKeyId();
$model = new \Models\Country();
return $model->checkAccess($countryId, $apiKey);
}
public function getCountryById(int $countryId): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
$model = new \Models\Country();
return $model->getCountryById($countryId, $apiKey);
}
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Country;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function showIndexPage(): void {
$this->redirectIfUnlogged();
$pageController = new Page();
$this->response = new \Views\Frontend();
$this->response->data = $pageController->getPageParams();
}
}

View File

@@ -0,0 +1,49 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Country;
class Page extends \Controllers\Pages\Base {
use \Traits\ApiKeys;
public $page = 'AdminCountry';
public function getPageParams(): array {
$dataController = new Data();
$countryId = $this->integerParam($this->f3->get('PARAMS.countryId'));
$hasAccess = $dataController->checkIfOperatorHasAccess($countryId);
if (!$hasAccess) {
$this->f3->error(404);
}
$country = $dataController->getCountryById($countryId);
$pageTitle = $this->getInternalPageTitleWithPostfix($country['value']);
$pageParams = [
'LOAD_DATATABLE' => true,
'LOAD_UPLOT' => true,
'LOAD_AUTOCOMPLETE' => true,
'LOAD_ACCEPT_LANGUAGE_PARSER' => true,
'HTML_FILE' => 'admin/country.html',
'COUNTRY' => $country,
'PAGE_TITLE' => $pageTitle,
'JS' => 'admin_country.js',
];
return parent::applyPageParams($pageParams);
}
}

View File

@@ -0,0 +1,272 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Data;
class Data extends \Controllers\Base {
// POST requests
public function enrichEntity(): array {
$controller = new \Controllers\Admin\Enrichment\Navigation();
return $controller->enrichEntity();
}
public function saveRule(): array {
$controller = new \Controllers\Admin\Rules\Navigation();
return $controller->saveRule();
}
public function removeFromBlacklist(): array {
$controller = new \Controllers\Admin\Blacklist\Navigation();
return $controller->removeItemFromList();
}
public function removeFromWatchlist(): array {
$controller = new \Controllers\Admin\Watchlist\Navigation();
return $controller->removeUserFromList();
}
public function manageUser(): array {
$controller = new \Controllers\Admin\User\Navigation();
return $controller->manageUser();
}
// GET requests
public function checkRule(): array {
$controller = new \Controllers\Admin\Rules\Navigation();
return $controller->checkRule();
}
public function getTimeFrameTotal(): array {
$controller = new \Controllers\Admin\Totals\Navigation();
return $controller->getTimeFrameTotal();
}
public function getCountries(): array {
$controller = new \Controllers\Admin\Countries\Navigation();
return $controller->getList();
}
public function getMap(): array {
$controller = new \Controllers\Admin\Countries\Navigation();
return $controller->getMap();
}
public function getIps(): array {
$controller = new \Controllers\Admin\IPs\Navigation();
return $controller->getList();
}
public function getEvents(): array {
$controller = new \Controllers\Admin\Events\Navigation();
return $controller->getList();
}
public function getLogbook(): array {
$controller = new \Controllers\Admin\Logbook\Navigation();
return $controller->getList();
}
public function getUsers(): array {
$controller = new \Controllers\Admin\Users\Navigation();
return $controller->getList();
}
public function getBots(): array {
$controller = new \Controllers\Admin\Bots\Navigation();
return $controller->getList();
}
public function getDevices(): array {
$controller = new \Controllers\Admin\Devices\Navigation();
return $controller->getList();
}
public function getResources(): array {
$controller = new \Controllers\Admin\Resources\Navigation();
return $controller->getList();
}
public function getDashboardStat(): array {
$controller = new \Controllers\Admin\Home\Navigation();
return $controller->getDashboardStat();
}
public function getTopTen(): array {
$controller = new \Controllers\Admin\Home\Navigation();
return $controller->getTopTen();
}
public function getChart(): array {
$controller = new \Controllers\Admin\Home\Navigation();
return $controller->getChart();
}
public function getEventDetails(): array {
$controller = new \Controllers\Admin\Events\Navigation();
return $controller->getEventDetails();
}
public function getLogbookDetails(): array {
$controller = new \Controllers\Admin\Logbook\Navigation();
return $controller->getLogbookDetails();
}
public function getEmailDetails(): array {
$controller = new \Controllers\Admin\Emails\Navigation();
return $controller->getEmailDetails();
}
public function getPhoneDetails(): array {
$controller = new \Controllers\Admin\Phones\Navigation();
return $controller->getPhoneDetails();
}
public function getUserDetails(): array {
$controller = new \Controllers\Admin\UserDetails\Navigation();
return $controller->getUserDetails();
}
public function getUserEnrichmentDetails(): array {
$controller = new \Controllers\Admin\UserDetails\Navigation();
return $controller->getUserEnrichmentDetails();
}
public function getNotCheckedEntitiesCount(): array {
$controller = new \Controllers\Admin\Enrichment\Navigation();
return $controller->getNotCheckedEntitiesCount();
}
public function getEmails(): array {
$controller = new \Controllers\Admin\Emails\Navigation();
return $controller->getList();
}
public function getPhones(): array {
$controller = new \Controllers\Admin\Phones\Navigation();
return $controller->getList();
}
public function getFieldAuditTrail(): array {
$controller = new \Controllers\Admin\Payloads\FieldAuditTrail\Navigation();
return $controller->getList();
}
public function getUserScoreDetails(): array {
$controller = new \Controllers\Admin\User\Navigation();
return $controller->getUserScoreDetails();
}
public function getIsps(): array {
$controller = new \Controllers\Admin\ISPs\Navigation();
return $controller->getList();
}
public function getDomains(): array {
$controller = new \Controllers\Admin\Domains\Navigation();
return $controller->getList();
}
public function getReviewUsersQueue(): array {
$controller = new \Controllers\Admin\ReviewQueue\Navigation();
return $controller->getList();
}
public function getReviewUsersQueueCount(): array {
$controller = new \Controllers\Admin\ReviewQueue\Navigation();
return $controller->getNumberOfNotReviewedUsers(false, true); // do not use cache, overall count
}
public function getIspDetails(): array {
$controller = new \Controllers\Admin\ISP\Navigation();
return $controller->getIspDetails();
}
public function getIpDetails(): array {
$controller = new \Controllers\Admin\IP\Navigation();
return $controller->getIpDetails();
}
public function getDeviceDetails(): array {
$controller = new \Controllers\Admin\Devices\Navigation();
return $controller->getDeviceDetails();
}
public function getBotDetails(): array {
$controller = new \Controllers\Admin\Bot\Navigation();
return $controller->getBotDetails();
}
public function getDomainDetails(): array {
$controller = new \Controllers\Admin\Domain\Navigation();
return $controller->getDomainDetails();
}
public function getSearchResults(): array {
$controller = new \Controllers\Admin\Search\Navigation();
return $controller->getSearchResults();
}
public function getBlacklist(): array {
$controller = new \Controllers\Admin\Blacklist\Navigation();
return $controller->getList();
}
public function getUsageStats(): array {
$controller = new \Controllers\Admin\Api\Navigation();
return $controller->getUsageStats();
}
}

View File

@@ -0,0 +1,204 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Data;
class Navigation extends \Controllers\Base {
use \Traits\Navigation;
private $dataController;
public function beforeroute(): void {
$errorCode = $this->validateCsrfToken();
if ($errorCode) {
$this->f3->error(403);
}
$this->redirectIfUnlogged();
$this->dataController = new Data();
$this->response = new \Views\Json();
}
// POST requests
public function enrichEntity(): void {
$this->response->data = $this->dataController->enrichEntity();
}
public function manageUser(): void {
$this->response->data = $this->dataController->manageUser();
}
public function removeFromWatchlist(): void {
$this->response->data = $this->dataController->removeFromWatchlist();
}
public function removeFromBlacklist(): void {
$this->response->data = $this->dataController->removeFromBlacklist();
}
public function saveRule(): void {
$this->response->data = $this->dataController->saveRule();
}
// GET requests
public function checkRule(): void {
$this->response->data = $this->dataController->checkRule();
}
public function getTimeFrameTotal(): void {
$this->response->data = $this->dataController->getTimeFrameTotal();
}
public function getCountries(): void {
$this->response->data = $this->dataController->getCountries();
}
public function getMap(): void {
$this->response->data = $this->dataController->getMap();
}
public function getIps(): void {
$this->response->data = $this->dataController->getIps();
}
public function getEvents(): void {
$this->response->data = $this->dataController->getEvents();
}
public function getLogbook(): void {
$this->response->data = $this->dataController->getLogbook();
}
public function getUsers(): void {
$this->response->data = $this->dataController->getUsers();
}
public function getBots(): void {
$this->response->data = $this->dataController->getBots();
}
public function getDevices(): void {
$this->response->data = $this->dataController->getDevices();
}
public function getResources(): void {
$this->response->data = $this->dataController->getResources();
}
public function getTopTen(): void {
$this->response->data = $this->dataController->getTopTen();
}
public function getDashboardStat(): void {
$this->response->data = $this->dataController->getDashboardStat();
}
public function getChart(): void {
$this->response->data = $this->dataController->getChart();
}
public function getEventDetails(): void {
$this->response->data = $this->dataController->getEventDetails();
}
public function getLogbookDetails(): void {
$this->response->data = $this->dataController->getLogbookDetails();
}
public function getEmailDetails(): void {
$this->response->data = $this->dataController->getEmailDetails();
}
public function getPhoneDetails(): void {
$this->response->data = $this->dataController->getPhoneDetails();
}
public function getUserDetails(): void {
$this->response->data = $this->dataController->getUserDetails();
}
public function getUserEnrichmentDetails(): void {
$this->response->data = $this->dataController->getUserEnrichmentDetails();
}
public function getNotCheckedEntitiesCount(): void {
$this->response->data = $this->dataController->getNotCheckedEntitiesCount();
}
public function getEmails(): void {
$this->response->data = $this->dataController->getEmails();
}
public function getPhones(): void {
$this->response->data = $this->dataController->getPhones();
}
public function getFieldAuditTrail(): void {
$this->response->data = $this->dataController->getFieldAuditTrail();
}
public function getUserScoreDetails(): void {
$this->response->data = $this->dataController->getUserScoreDetails();
}
public function getIsps(): void {
$this->response->data = $this->dataController->getIsps();
}
public function getDomains(): void {
$this->response->data = $this->dataController->getDomains();
}
public function getIspDetails(): void {
$this->response->data = $this->dataController->getIspDetails();
}
public function getIpDetails(): void {
$this->response->data = $this->dataController->getIpDetails();
}
public function getDeviceDetails(): void {
$this->response->data = $this->dataController->getDeviceDetails();
}
public function getBotDetails(): void {
$this->response->data = $this->dataController->getBotDetails();
}
public function getDomainDetails(): void {
$this->response->data = $this->dataController->getDomainDetails();
}
public function getReviewUsersQueue(): void {
$this->response->data = $this->dataController->getReviewUsersQueue();
}
public function getReviewUsersQueueCount(): void {
$this->response->data = $this->dataController->getReviewUsersQueueCount();
}
public function getSearchResults(): void {
$this->response->data = $this->dataController->getSearchResults();
}
public function getBlacklist(): void {
$this->response->data = $this->dataController->getBlacklist();
}
public function getUsageStats(): void {
$this->response->data = $this->dataController->getUsageStats();
}
}

View File

@@ -0,0 +1,65 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Devices;
class Data extends \Controllers\Base {
public function getList(int $apiKey): array {
$result = [];
$model = new \Models\Grid\Devices\Grid($apiKey);
$ipId = $this->f3->get('REQUEST.ipId');
$userId = $this->f3->get('REQUEST.userId');
$resourceId = $this->f3->get('REQUEST.resourceId');
if (isset($ipId) && is_numeric($ipId)) {
$result = $model->getDevicesByIpId($ipId);
}
if (isset($userId) && is_numeric($userId)) {
$result = $model->getDevicesByUserId($userId);
}
if (isset($resourceId) && is_numeric($resourceId)) {
$result = $model->getDevicesByResourceId($resourceId);
}
if (!$result) {
$result = $model->getAllDevices();
}
return $result;
}
public function getDeviceDetails(int $apiKey): array {
$params = $this->f3->get('GET');
$id = $params['id'];
$model = new \Models\Device();
$details = $model->getFullDeviceInfoById($id, $apiKey);
$details['enrichable'] = $this->isEnrichable($apiKey);
$tsColumns = ['created'];
\Utils\TimeZones::localizeTimestampsForActiveOperator($tsColumns, $details);
return $details;
}
private function isEnrichable(int $apiKey): bool {
$model = new \Models\ApiKeys();
return $model->attributeIsEnrichable('ua', $apiKey);
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Devices;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function getList(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getList($apiKey) : [];
}
public function getDeviceDetails(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getDeviceDetails($apiKey) : [];
}
}

View File

@@ -0,0 +1,64 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Domain;
class Data extends \Controllers\Base {
use \Traits\ApiKeys;
public function proceedPostRequest(array $params): array {
return match ($params['cmd']) {
'reenrichment' => $this->enrichEntity($params),
default => []
};
}
public function enrichEntity(array $params): array {
$dataController = new \Controllers\Admin\Enrichment\Data();
$apiKey = $this->getCurrentOperatorApiKeyId();
$enrichmentKey = $this->getCurrentOperatorEnrichmentKeyString();
$type = $params['type'];
$search = $params['search'] ?? null;
$entityId = isset($params['entityId']) ? (int) $params['entityId'] : null;
return $dataController->enrichEntity($type, $search, $entityId, $apiKey, $enrichmentKey);
}
public function checkIfOperatorHasAccess(int $domainId): bool {
$apiKey = $this->getCurrentOperatorApiKeyId();
$model = new \Models\Domain();
return $model->checkAccess($domainId, $apiKey);
}
public function getDomainDetails(int $domainId): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
$model = new \Models\Domain();
$result = $model->getFullDomainInfoById($domainId, $apiKey);
$tsColumns = ['lastseen'];
\Utils\TimeZones::localizeTimestampsForActiveOperator($tsColumns, $result);
return $result;
}
public function isEnrichable(): bool {
$apiKey = $this->getCurrentOperatorApiKeyId();
$model = new \Models\ApiKeys();
return $model->attributeIsEnrichable('domain', $apiKey);
}
}

View File

@@ -0,0 +1,41 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Domain;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function showIndexPage(): void {
$this->redirectIfUnlogged();
$pageController = new Page();
$this->response = new \Views\Frontend();
$this->response->data = $pageController->getPageParams();
}
public function getDomainDetails(): array {
$dataController = new Data();
$domainId = $this->f3->get('REQUEST.domainId');
$hasAccess = $dataController->checkIfOperatorHasAccess($domainId);
if (!$hasAccess) {
$this->f3->error(404);
}
return $dataController->getDomainDetails($domainId);
}
}

View File

@@ -0,0 +1,60 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Domain;
class Page extends \Controllers\Pages\Base {
public $page = 'AdminDomain';
public function getPageParams(): array {
$dataController = new Data();
$domainId = $this->integerParam($this->f3->get('PARAMS.domainId'));
$hasAccess = $dataController->checkIfOperatorHasAccess($domainId);
if (!$hasAccess) {
$this->f3->error(404);
}
$domain = $dataController->getDomainDetails($domainId);
$pageTitle = $this->getInternalPageTitleWithPostfix($domain['domain']);
$isEnrichable = $dataController->isEnrichable();
$pageParams = [
'LOAD_DATATABLE' => true,
'LOAD_JVECTORMAP' => true,
'LOAD_AUTOCOMPLETE' => true,
'HTML_FILE' => 'admin/domain.html',
'DOMAIN' => $domain,
'PAGE_TITLE' => $pageTitle,
'LOAD_UPLOT' => true,
'LOAD_ACCEPT_LANGUAGE_PARSER' => true,
'JS' => 'admin_domain.js',
'IS_ENRICHABLE' => $isEnrichable,
];
if ($this->isPostRequest()) {
$params = $this->f3->get('POST');
$operationResponse = $dataController->proceedPostRequest($params);
$pageParams = array_merge($pageParams, $operationResponse);
$pageParams['CMD'] = $params['cmd'];
// recall domain data
$pageParams['DOMAIN'] = $dataController->getDomainDetails($domainId);
}
return parent::applyPageParams($pageParams);
}
}

View File

@@ -0,0 +1,42 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Domains;
class Data extends \Controllers\Base {
public function getList(int $apiKey): array {
$result = [];
$model = new \Models\Grid\Domains\Grid($apiKey);
$domainId = $this->f3->get('REQUEST.domainId');
if (isset($domainId)) {
$result = $model->getDomainsBySameIpDomainId($domainId);
}
if (!$result) {
$result = $model->getAllDomains();
}
$ids = array_column($result['data'], 'id');
if ($ids) {
$model = new \Models\Domain();
$model->updateTotalsByEntityIds($ids, $apiKey);
$result['data'] = $model->refreshTotals($result['data'], $apiKey);
}
return $result;
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Domains;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function showIndexPage(): void {
$this->redirectIfUnlogged();
$pageController = new Page();
$this->response = new \Views\Frontend();
$this->response->data = $pageController->getPageParams();
}
public function getList(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getList($apiKey) : [];
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Domains;
class Page extends \Controllers\Pages\Base {
public $page = 'AdminDomains';
public function getPageParams(): array {
$searchPlacholder = $this->f3->get('AdminDomains_search_placeholder');
$pageParams = [
'SEARCH_PLACEHOLDER' => $searchPlacholder,
'LOAD_UPLOT' => true,
'LOAD_DATATABLE' => true,
'LOAD_AUTOCOMPLETE' => true,
'HTML_FILE' => 'admin/domains.html',
'JS' => 'admin_domains.js',
];
return parent::applyPageParams($pageParams);
}
}

View File

@@ -0,0 +1,51 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Emails;
class Data extends \Controllers\Base {
public function getList(int $apiKey): array {
$result = [];
$model = new \Models\Grid\Emails\Grid($apiKey);
$userId = $this->f3->get('REQUEST.userId');
if (isset($userId) && is_numeric($userId)) {
$result = $model->getEmailsByUserId($userId);
}
return $result;
}
public function getEmailDetails(int $apiKey): array {
$params = $this->f3->get('GET');
$id = $params['id'];
$model = new \Models\Email();
$details = $model->getEmailDetails($id, $apiKey);
$details['enrichable'] = $this->isEnrichable($apiKey);
$tsColumns = ['email_created', 'email_lastseen', 'domain_lastseen', 'domain_created'];
\Utils\TimeZones::localizeTimestampsForActiveOperator($tsColumns, $details);
return $details;
}
private function isEnrichable(int $apiKey): bool {
$model = new \Models\ApiKeys();
return $model->attributeIsEnrichable('email', $apiKey);
}
}

View File

@@ -0,0 +1,33 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Emails;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function getList(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getList($apiKey) : [];
}
public function getEmailDetails(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getEmailDetails($apiKey) : [];
}
}

View File

@@ -0,0 +1,252 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Enrichment;
class Data extends \Controllers\Base {
public function enrichEntity(string $type, ?string $search, ?int $entityId, int $apiKey, ?string $enrichmentKey): array {
if ($enrichmentKey === null) {
return ['ERROR_CODE' => \Utils\ErrorCodes::ENRICHMENT_API_KEY_DOES_NOT_EXIST];
}
set_error_handler([\Utils\ErrorHandler::class, 'exceptionErrorHandler']);
$search = $search !== null ? ['value' => $search] : null;
$result = $this->enrichEntityProcess($type, $search, $entityId, $apiKey, $enrichmentKey);
restore_error_handler();
return $result;
}
private function enrichEntityProcess(string $type, ?array $search, ?int $entityId, int $apiKey, ?string $enrichmentKey): array {
$processErrorMessage = ['ERROR_CODE' => \Utils\ErrorCodes::ENRICHMENT_API_UNKNOWN_ERROR];
if ($type === 'device') {
if ($entityId !== null) {
$model = new \Models\Device();
$device = $model->getFullDeviceInfoById($entityId, $apiKey);
if ($device !== []) {
$entityId = $device['ua_id'];
$type = 'ua';
} else {
return $processErrorMessage;
}
} else {
return $processErrorMessage;
}
}
$model = new \Models\ApiKeys();
$attributes = $model->enrichableAttributes($apiKey);
if (!array_key_exists($type, $attributes)) {
return ['ERROR_CODE' => \Utils\ErrorCodes::ENRICHMENT_API_ATTRIBUTE_IS_UNAVAILABLE];
}
$modelDb = null;
$modelResult = null;
$extraModel = null;
switch ($type) {
case 'ip':
$modelDb = new \Models\Ip();
$modelResult = new \Models\Enrichment\Ip();
$extraModel = new \Models\Enrichment\LocalhostIp();
break;
case 'email':
$modelDb = new \Models\Email();
$modelResult = new \Models\Enrichment\Email();
break;
case 'domain':
$modelDb = new \Models\Domain();
$modelResult = new \Models\Enrichment\DomainFound();
$extraModel = new \Models\Enrichment\DomainNotFound();
break;
case 'phone':
$modelDb = new \Models\Phone();
$modelResult = new \Models\Enrichment\PhoneValid();
$extraModel = new \Models\Enrichment\PhoneInvalid();
break;
case 'ua':
$modelDb = new \Models\Device();
$modelResult = new \Models\Enrichment\Device();
break;
}
if ($modelDb === null) {
return $processErrorMessage;
}
$value = $entityId !== null ? $modelDb->extractById($entityId, $apiKey) : $search;
if ($value === null || $value === []) {
return $processErrorMessage;
}
$apiError = null;
try {
[$statusCode, $response,] = $this->enrichEntityByValue($type, $value, $enrichmentKey);
$error = \Utils\ApiResponseFormats::getErrorResponseFormat();
$apiError = \Utils\ApiResponseFormats::matchResponse($response[$type] ?? [], $error) ? $response[$type]['error'] : null;
} catch (\ErrorException $e) {
return $processErrorMessage;
}
if ($statusCode === 403) {
return ['ERROR_CODE' => \Utils\ErrorCodes::ENRICHMENT_API_KEY_OVERUSE];
}
if ($type === 'ip') {
// do not raise on bogon ip
if ($apiError === \Utils\Constants::get('ENRICHMENT_IP_IS_NOT_FOUND')) {
return ['ERROR_CODE' => \Utils\ErrorCodes::ENRICHMENT_API_IP_NOT_FOUND];
} elseif ($apiError !== null && $apiError !== \Utils\Constants::get('ENRICHMENT_IP_IS_BOGON') || $statusCode !== 200 || $response[$type] === null) {
return $processErrorMessage;
}
} elseif ($apiError !== null || $statusCode !== 200 || $response[$type] === null) {
return $processErrorMessage;
}
try {
$modelResult->init($response[$type]);
} catch (\ErrorException $e) {
if ($extraModel === null) {
return $processErrorMessage;
}
try {
$extraModel->init($response[$type]);
$modelResult = $extraModel;
} catch (\ErrorException $e) {
return $processErrorMessage;
}
}
// change value in db only if $entityId was passed
if ($entityId !== null) {
try {
$modelResult->updateEntityInDb($entityId, $apiKey);
} catch (\ErrorException $e) {
return $processErrorMessage;
}
}
return [
$type => $response[$type],
'SUCCESS_MESSAGE' => $this->f3->get('AdminEnrichment_success_message'),
];
}
private function validateResponse(string $requestType, int $statusCode, ?array $result, string $errorMessage): bool|string|int {
if (!is_array($result)) {
return \Utils\ErrorCodes::ENRICHMENT_API_UNKNOWN_ERROR;
}
if ($statusCode === 200 && is_array($result) && is_array($result[$requestType])) {
return false;
}
$details = $result['detail'] ?? null;
if ($details) {
if (is_array($details)) {
$messages = array_map(function ($detail) {
if (isset($detail['msg']) && $detail['msg'] !== null && $detail['msg'] !== '') {
return $detail['msg'];
}
}, $details);
$messages = implode('; ', $messages);
} else {
$messages = $details;
}
}
if (strlen($errorMessage) > 0) {
\Utils\Logger::log('Enrichment API web error', $errorMessage);
}
if (!isset($messages) || strlen($messages) < 1) {
return \Utils\ErrorCodes::ENRICHMENT_API_UNKNOWN_ERROR;
}
return $messages;
}
private function enrichEntityByValue(string $type, array $value, string $enrichmentKey): array {
$apiUrl = \Utils\Variables::getEnrichtmentApi();
$postFields = [
$type => $value['value'],
];
$options = [
'method' => 'POST',
'header' => [
'Content-Type: application/json',
'Authorization: Bearer ' . $enrichmentKey,
'User-Agent: ' . $this->f3->get('USER_AGENT'),
],
'content' => \json_encode($postFields),
];
/** @var array{request: array<string>, body: string, headers: array<string>, engine: string, cached: bool, error: string} $result */
$result = \Web::instance()->request(
url: sprintf('%s/query', $apiUrl),
options: $options,
);
$matches = [];
preg_match('/^HTTP\/(\d+)(?:\.\d)? (\d{3})/', $result['headers'][0], $matches);
$jsonResponse = json_decode($result['body'], true);
$statusCode = (int) ($matches[2] ?? 0);
$errorMessages = $this->validateResponse($type, $statusCode, $jsonResponse, $result['error']);
return [$statusCode, $jsonResponse, $errorMessages];
}
public function getNotCheckedEntitiesCount(int $apiKey): array {
$model = new \Models\ApiKeys();
$models = $model->enrichableAttributes($apiKey);
$result = [];
foreach ($models as $type => $model) {
$result[$type] = (new $model())->countNotChecked($apiKey);
}
return $result;
}
public function getNotCheckedExists(int $apiKey): bool {
$model = new \Models\ApiKeys();
$models = $model->enrichableAttributes($apiKey);
foreach ($models as $model) {
if ((new $model())->notCheckedExists($apiKey)) {
return true;
}
}
return false;
}
public function getNotCheckedEntitiesByUserId(int $userId, int $apiKey): array {
$model = new \Models\ApiKeys();
$models = $model->enrichableAttributes($apiKey);
$result = [];
foreach ($models as $type => $model) {
$result[$type] = (new $model())->notCheckedForUserId($userId, $apiKey);
}
return $result;
}
}

View File

@@ -0,0 +1,39 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Enrichment;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function enrichEntity(): array {
$dataController = new Data();
$apiKey = $this->getCurrentOperatorApiKeyId();
$enrichmentKey = $this->getCurrentOperatorEnrichmentKeyString();
$params = $this->f3->get('POST');
$type = $params['type'];
$search = $params['search'] ?? null;
$entityId = $params['entityId'] ?? null;
return $dataController->enrichEntity($type, $search, $entityId, $apiKey, $enrichmentKey);
}
public function getNotCheckedEntitiesCount(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getNotCheckedEntitiesCount($apiKey) : [];
}
}

View File

@@ -0,0 +1,94 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Events;
class Data extends \Controllers\Base {
public function getList(int $apiKey): array {
$result = [];
$model = new \Models\Grid\Events\Grid($apiKey);
$ipId = $this->f3->get('REQUEST.ipId');
$ispId = $this->f3->get('REQUEST.ispId');
$userId = $this->f3->get('REQUEST.userId');
$botId = $this->f3->get('REQUEST.botId');
$domainId = $this->f3->get('REQUEST.domainId');
$countryId = $this->f3->get('REQUEST.countryId');
$resourceId = $this->f3->get('REQUEST.resourceId');
if (isset($ipId) && is_numeric($ipId)) {
$result = $model->getEventsByIpId($ipId);
}
if (isset($ispId)) {
$result = $model->getEventsByIspId($ispId);
}
if (isset($domainId) && is_numeric($domainId)) {
$result = $model->getEventsByDomainId($domainId);
}
if (isset($userId) && is_numeric($userId)) {
$result = $model->getEventsByUserId($userId);
}
if (isset($countryId) && is_numeric($countryId)) {
$result = $model->getEventsByCountryId($countryId);
}
if (isset($resourceId) && is_numeric($resourceId)) {
$result = $model->getEventsByResourceId($resourceId);
}
if (isset($botId) && is_numeric($botId)) {
$result = $model->getEventsByDeviceId($botId);
}
if (!$result) {
$result = $model->getAllEvents();
}
return $result;
}
public function getEventDetails(int $apiKey): array {
$params = $this->f3->get('GET');
$id = $params['id'];
$model = new \Models\Event();
$result = $model->getEventDetails($id, $apiKey);
$tsColumns = ['device_created', 'latest_decision', 'added_to_review', 'score_updated_at', 'event_time'];
\Utils\TimeZones::localizeTimestampsForActiveOperator($tsColumns, $result);
if (isset($result['event_type_id']) && $result['event_type_id'] === \Utils\Constants::get('FIELD_EDIT_EVENT_TYPE_ID')) {
$model = new \Models\FieldAuditTrail();
$result['event_payload'] = json_encode($model->getByEventId($id, $apiKey));
}
return $result;
}
public function getAllEventTypes(): array {
$model = new \Models\EventType();
return $model->getAll();
}
public function getAllDeviceTypes(): array {
return \Utils\Constants::get('DEVICE_TYPES');
}
}

View File

@@ -0,0 +1,41 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Events;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function showIndexPage(): void {
$this->redirectIfUnlogged();
$pageController = new Page();
$this->response = new \Views\Frontend();
$this->response->data = $pageController->getPageParams();
}
public function getList(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getList($apiKey) : [];
}
public function getEventDetails(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getEventDetails($apiKey) : [];
}
}

View File

@@ -0,0 +1,43 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Events;
class Page extends \Controllers\Pages\Base {
public $page = 'AdminEvents';
public function getPageParams(): array {
$searchPlacholder = $this->f3->get('AdminEvents_search_placeholder');
$controller = new Data();
$apiKey = $this->getCurrentOperatorApiKeyId();
$rulesController = new \Controllers\Admin\Rules\Data();
$pageParams = [
'SEARCH_PLACEHOLDER' => $searchPlacholder,
'LOAD_ACCEPT_LANGUAGE_PARSER' => true,
'LOAD_UPLOT' => true,
'LOAD_DATATABLE' => true,
'LOAD_CHOICES' => true,
'LOAD_AUTOCOMPLETE' => true,
'HTML_FILE' => 'admin/events.html',
'JS' => 'admin_events.js',
'EVENT_TYPES' => $controller->getAllEventTypes(),
'DEVICE_TYPES' => $controller->getAllDeviceTypes(),
'RULES' => $rulesController->getAllRulesByApiKey($apiKey),
];
return parent::applyPageParams($pageParams);
}
}

View File

@@ -0,0 +1,94 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Home;
class Data extends \Controllers\Base {
use \Traits\DateRange;
public function getChart(int $apiKey): array {
$request = $this->f3->get('REQUEST');
$mode = $request['mode'];
$modelMap = \Utils\Constants::get('CHART_MODEL_MAP');
$model = array_key_exists($mode, $modelMap) ? new $modelMap[$mode]() : null;
return $model ? $model->getData($apiKey) : [[], []];
}
public function getStat(int $apiKey): array {
$request = $this->f3->get('REQUEST');
$dateRange = $this->getDatesRange($request);
$mode = $request['mode'];
$model = new \Models\Dashboard();
$result = [
'total' => null,
'allTimeTotal' => null,
];
switch ($mode) {
case 'totalEvents':
$result['total'] = $model->getTotalEvents($dateRange, $apiKey);
$result['allTimeTotal'] = $model->getTotalEvents(null, $apiKey);
break;
case 'totalUsers':
$result['total'] = $model->getTotalUsers($dateRange, $apiKey);
$result['allTimeTotal'] = $model->getTotalUsers(null, $apiKey);
break;
case 'totalIps':
$result['total'] = $model->getTotalIps($dateRange, $apiKey);
$result['allTimeTotal'] = $model->getTotalIps(null, $apiKey);
break;
case 'totalCountries':
$result['total'] = $model->getTotalCountries($dateRange, $apiKey);
$result['allTimeTotal'] = $model->getTotalCountries(null, $apiKey);
break;
case 'totalUrls':
$result['total'] = $model->getTotalResources($dateRange, $apiKey);
$result['allTimeTotal'] = $model->getTotalResources(null, $apiKey);
break;
case 'totalUsersForReview':
$result['total'] = $model->getTotalUsersForReview($dateRange, $apiKey);
$result['allTimeTotal'] = $model->getTotalUsersForReview(null, $apiKey);
break;
case 'totalBlockedUsers':
$result['total'] = $model->getTotalBlockedUsers($dateRange, $apiKey);
$result['allTimeTotal'] = $model->getTotalBlockedUsers(null, $apiKey);
break;
}
return $result;
}
public function getTopTen(int $apiKey): array {
$params = $this->f3->get('GET');
$dateRange = $this->getDatesRange($params);
$mode = $params['mode'];
$modelMap = \Utils\Constants::get('TOP_TEN_MODELS_MAP');
$model = array_key_exists($mode, $modelMap) ? new $modelMap[$mode]() : null;
$data = $model ? $model->getList($apiKey, $dateRange) : [];
$total = count($data);
return [
'draw' => $params['draw'] ?? 1,
'recordsTotal' => $total,
'recordsFiltered' => $total,
'data' => $data,
];
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Home;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function showIndexPage(): void {
$this->redirectIfUnlogged('/login');
$pageController = new Page();
$this->response = new \Views\Frontend();
$this->response->data = $pageController->getPageParams();
}
public function getDashboardStat(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getStat($apiKey) : [];
}
public function getTopTen(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getTopTen($apiKey) : [];
}
public function getChart(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getChart($apiKey) : [];
}
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Home;
class Page extends \Controllers\Pages\Base {
public $page = 'AdminHome';
public function getPageParams(): array {
$pageParams = [
'LOAD_DATATABLE' => true,
'LOAD_AUTOCOMPLETE' => true,
'HTML_FILE' => 'admin/home.html',
'JS' => 'admin_dashboard.js',
];
return parent::applyPageParams($pageParams);
}
}

View File

@@ -0,0 +1,79 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\IP;
class Data extends \Controllers\Base {
use \Traits\ApiKeys;
public function proceedPostRequest(array $params): array {
return match ($params['cmd']) {
'reenrichment' => $this->enrichEntity($params),
default => []
};
}
public function enrichEntity(array $params): array {
$dataController = new \Controllers\Admin\Enrichment\Data();
$apiKey = $this->getCurrentOperatorApiKeyId();
$enrichmentKey = $this->getCurrentOperatorEnrichmentKeyString();
$type = $params['type'];
$search = $params['search'] ?? null;
$entityId = isset($params['entityId']) ? (int) $params['entityId'] : null;
return $dataController->enrichEntity($type, $search, $entityId, $apiKey, $enrichmentKey);
}
public function checkIfOperatorHasAccess(int $ipId): bool {
$apiKey = $this->getCurrentOperatorApiKeyId();
$model = new \Models\Ip();
return $model->checkAccess($ipId, $apiKey);
}
public function getIpDetails(int $ipId): array {
$result = $this->getFullIpInfoById($ipId);
return [
'full_country' => $result['full_country'],
'country_id' => $result['country_id'],
'country_iso' => $result['country_iso'],
'asn' => $result['asn'],
'blocklist' => $result['blocklist'],
'fraud_detected' => $result['fraud_detected'],
'data_center' => $result['data_center'],
'vpn' => $result['vpn'],
'tor' => $result['tor'],
'relay' => $result['relay'],
'starlink' => $result['starlink'],
'ispid' => $result['ispid'],
];
}
public function getFullIpInfoById(int $ipId): array {
$model = new \Models\Ip();
$result = $model->getFullIpInfoById($ipId);
$result['lastseen'] = \Utils\ElapsedDate::short($result['lastseen']);
return $result;
}
public function isEnrichable(): bool {
$apiKey = $this->getCurrentOperatorApiKeyId();
$model = new \Models\ApiKeys();
return $model->attributeIsEnrichable('ip', $apiKey);
}
}

View File

@@ -0,0 +1,41 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\IP;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function showIndexPage(): void {
$this->redirectIfUnlogged();
$pageController = new Page();
$this->response = new \Views\Frontend();
$this->response->data = $pageController->getPageParams();
}
public function getIpDetails(): array {
$dataController = new Data();
$ipId = $this->f3->get('REQUEST.ipId');
$hasAccess = $dataController->checkIfOperatorHasAccess($ipId);
if (!$hasAccess) {
$this->f3->error(404);
}
return $dataController->getIpDetails($ipId);
}
}

View File

@@ -0,0 +1,58 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\IP;
class Page extends \Controllers\Pages\Base {
public $page = 'AdminIp';
public function getPageParams(): array {
$dataController = new Data();
$ipId = $this->integerParam($this->f3->get('PARAMS.ipId'));
$hasAccess = $dataController->checkIfOperatorHasAccess($ipId);
if (!$hasAccess) {
$this->f3->error(404);
}
$ip = $dataController->getFullIpInfoById($ipId);
$pageTitle = $this->getInternalPageTitleWithPostfix($ip['ip']);
$isEnrichable = $dataController->isEnrichable();
$pageParams = [
'LOAD_DATATABLE' => true,
'LOAD_AUTOCOMPLETE' => true,
'HTML_FILE' => 'admin/ip.html',
'PAGE_TITLE' => $pageTitle,
'IP' => $ip,
'LOAD_UPLOT' => true,
'LOAD_ACCEPT_LANGUAGE_PARSER' => true,
'JS' => 'admin_ip.js',
'IS_ENRICHABLE' => $isEnrichable,
];
if ($this->isPostRequest()) {
$params = $this->f3->get('POST');
$operationResponse = $dataController->proceedPostRequest($params);
$pageParams = array_merge($pageParams, $operationResponse);
$pageParams['CMD'] = $params['cmd'];
// recall ip data
$pageParams['IP'] = $dataController->getFullIpInfoById($ipId);
}
return parent::applyPageParams($pageParams);
}
}

View File

@@ -0,0 +1,67 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\IPs;
class Data extends \Controllers\Base {
public function getList(int $apiKey): array {
$result = [];
$model = new \Models\Grid\Ips\Grid($apiKey);
$ispId = $this->f3->get('REQUEST.ispId');
$userId = $this->f3->get('REQUEST.userId');
$botId = $this->f3->get('REQUEST.botId');
$domainId = $this->f3->get('REQUEST.domainId');
$countryId = $this->f3->get('REQUEST.countryId');
$resourceId = $this->f3->get('REQUEST.resourceId');
if (isset($userId) && is_numeric($userId)) {
$result = $model->getIpsByUserId($userId);
}
if (isset($ispId)) {
$result = $model->getIpsByIspId($ispId);
}
if (isset($domainId) && is_numeric($domainId)) {
$result = $model->getIpsByDomainId($domainId);
}
if (isset($countryId) && is_numeric($countryId)) {
$result = $model->getIpsByCountryId($countryId);
}
if (isset($botId) && is_numeric($botId)) {
$result = $model->getIpsByDeviceId($botId);
}
if (isset($resourceId) && is_numeric($resourceId)) {
$result = $model->getIpsByResourceId($resourceId);
}
if (!$result) {
$result = $model->getAllIps();
}
$ids = array_column($result['data'], 'id');
if ($ids) {
$model = new \Models\Ip();
$model->updateTotalsByEntityIds($ids, $apiKey);
$result['data'] = $model->refreshTotals($result['data'], $apiKey);
}
return $result;
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\IPs;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function showIndexPage(): void {
$this->redirectIfUnlogged();
$pageController = new Page();
$this->response = new \Views\Frontend();
$this->response->data = $pageController->getPageParams();
}
public function getList(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getList($apiKey) : [];
}
}

View File

@@ -0,0 +1,37 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\IPs;
class Page extends \Controllers\Pages\Base {
public $page = 'AdminIps';
public function getPageParams(): array {
$searchPlacholder = $this->f3->get('AdminIps_search_placeholder');
$pageParams = [
'SEARCH_PLACEHOLDER' => $searchPlacholder,
'LOAD_UPLOT' => true,
'LOAD_DATATABLE' => true,
'LOAD_CHOICES' => true,
'LOAD_AUTOCOMPLETE' => true,
'HTML_FILE' => 'admin/ips.html',
'JS' => 'admin_ips.js',
'IP_TYPES' => \Utils\Constants::get('IP_TYPES'),
];
return parent::applyPageParams($pageParams);
}
}

View File

@@ -0,0 +1,60 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\ISP;
class Data extends \Controllers\Base {
use \Traits\ApiKeys;
public function checkIfOperatorHasAccess(int $ispId): bool {
$apiKey = $this->getCurrentOperatorApiKeyId();
$model = new \Models\Isp();
return $model->checkAccess($ispId, $apiKey);
}
public function getFullIspInfoById(int $ispId): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
$model = new \Models\Isp();
$result = $model->getFullIspInfoById($ispId, $apiKey);
$result['lastseen'] = \Utils\ElapsedDate::short($result['lastseen']);
return $result;
}
private function getNumberOfIpsByIspId(int $ispId): int {
$apiKey = $this->getCurrentOperatorApiKeyId();
$model = new \Models\Isp();
return $model->getIpCountById($ispId, $apiKey);
}
public function getIspDetails(int $ispId): array {
$result = [];
$data = $this->getFullIspInfoById($ispId);
if (array_key_exists('asn', $data)) {
$result = [
'asn' => $data['asn'],
'total_fraud' => $data['total_fraud'],
'total_visit' => $data['total_visit'],
'total_account' => $data['total_account'],
'total_ip' => $this->getNumberOfIpsByIspId($ispId),
];
}
return $result;
}
}

View File

@@ -0,0 +1,41 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\ISP;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function showIndexPage(): void {
$this->redirectIfUnlogged();
$pageController = new Page();
$this->response = new \Views\Frontend();
$this->response->data = $pageController->getPageParams();
}
public function getIspDetails(): array {
$dataController = new Data();
$ispId = $this->f3->get('REQUEST.ispId');
$hasAccess = $dataController->checkIfOperatorHasAccess($ispId);
if (!$hasAccess) {
$this->f3->error(404);
}
return $dataController->getIspDetails($ispId);
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\ISP;
class Page extends \Controllers\Pages\Base {
public $page = 'AdminIsp';
public function getPageParams(): array {
$dataController = new Data();
$ispId = $this->integerParam($this->f3->get('PARAMS.ispId'));
$hasAccess = $dataController->checkIfOperatorHasAccess($ispId);
if (!$hasAccess) {
$this->f3->error(404);
}
$isp = $dataController->getFullIspInfoById($ispId);
$pageTitle = $this->getInternalPageTitleWithPostfix(strval($isp['asn']));
$pageParams = [
'LOAD_DATATABLE' => true,
'LOAD_JVECTORMAP' => true,
'LOAD_AUTOCOMPLETE' => true,
'HTML_FILE' => 'admin/isp.html',
'ISP' => $isp,
'PAGE_TITLE' => $pageTitle,
'LOAD_UPLOT' => true,
'LOAD_ACCEPT_LANGUAGE_PARSER' => true,
'JS' => 'admin_isp.js',
];
return parent::applyPageParams($pageParams);
}
}

View File

@@ -0,0 +1,56 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\ISPs;
class Data extends \Controllers\Base {
public function getList(int $apiKey): array {
$result = [];
$model = new \Models\Grid\Isps\Grid($apiKey);
$userId = $this->f3->get('REQUEST.userId');
$domainId = $this->f3->get('REQUEST.domainId');
$countryId = $this->f3->get('REQUEST.countryId');
$resourceId = $this->f3->get('REQUEST.resourceId');
if (isset($userId) && is_numeric($userId)) {
$result = $model->getIspsByUserId($userId);
}
if (isset($domainId) && is_numeric($domainId)) {
$result = $model->getIspsByDomainId($domainId);
}
if (isset($countryId) && is_numeric($countryId)) {
$result = $model->getIspsByCountryId($countryId);
}
if (isset($resourceId) && is_numeric($resourceId)) {
$result = $model->getIspsByResourceId($resourceId);
}
if (!$result) {
$result = $model->getAllIsps();
}
$ids = array_column($result['data'], 'id');
if ($ids) {
$model = new \Models\Isp();
$model->updateTotalsByEntityIds($ids, $apiKey);
$result['data'] = $model->refreshTotals($result['data'], $apiKey);
}
return $result;
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\ISPs;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function showIndexPage(): void {
$this->redirectIfUnlogged();
$pageController = new Page();
$this->response = new \Views\Frontend();
$this->response->data = $pageController->getPageParams();
}
public function getList(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getList($apiKey) : [];
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\ISPs;
class Page extends \Controllers\Pages\Base {
public $page = 'AdminIsps';
public function getPageParams(): array {
$searchPlacholder = $this->f3->get('AdminIsps_search_placeholder');
$pageParams = [
'SEARCH_PLACEHOLDER' => $searchPlacholder,
'LOAD_UPLOT' => true,
'LOAD_DATATABLE' => true,
'LOAD_AUTOCOMPLETE' => true,
'HTML_FILE' => 'admin/isps.html',
'JS' => 'admin_isps.js',
];
return parent::applyPageParams($pageParams);
}
}

View File

@@ -0,0 +1,32 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Logbook;
class Data extends \Controllers\Base {
public function getList(int $apiKey): array {
$model = new \Models\Grid\Logbook\Grid($apiKey);
return $model->getAllLogbookEvents();
}
public function getLogbookDetails(int $apiKey): array {
$params = $this->f3->get('GET');
$id = $params['id'];
$model = new \Models\Logbook();
return $model->getLogbookDetails($id, $apiKey);
}
}

View File

@@ -0,0 +1,42 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Logbook;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function showIndexPage(): void {
$this->redirectIfUnlogged();
$pageController = new Page();
$this->response = new \Views\Frontend();
$this->response->data = $pageController->getPageParams();
}
// TODO: daterange ~= event_logbook.started?
public function getList(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getList($apiKey) : [];
}
public function getLogbookDetails(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getLogbookDetails($apiKey) : [];
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Logbook;
class Page extends \Controllers\Pages\Base {
public $page = 'AdminLogbook';
public function getPageParams(): array {
$searchPlacholder = $this->f3->get('AdminLogbook_search_placeholder');
$pageParams = [
'SEARCH_PLACEHOLDER' => $searchPlacholder,
'LOAD_UPLOT' => true,
'LOAD_DATATABLE' => true,
'LOAD_AUTOCOMPLETE' => true,
'HTML_FILE' => 'admin/logbook.html',
'JS' => 'admin_logbook.js',
];
return parent::applyPageParams($pageParams);
}
}

View File

@@ -0,0 +1,108 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\ManualCheck;
class Data extends \Controllers\Base {
use \Traits\ApiKeys;
public function proceedPostRequest(array $params): array {
return $this->performSearch($params);
}
public function performSearch(array $params): array {
$pageParams = [
'SEARCH_VALUES' => $params,
];
$apiKey = $this->getCurrentOperatorApiKeyId();
$enrichmentKey = $this->getCurrentOperatorEnrichmentKeyString();
$errorCode = $this->validateSearch($params, $enrichmentKey);
if ($errorCode) {
$pageParams['ERROR_CODE'] = $errorCode;
return $pageParams;
}
$type = $params['type'];
$controller = new \Controllers\Admin\Enrichment\Data();
$result = $controller->enrichEntity($type, $params['search'], null, $apiKey, $enrichmentKey);
if (isset($result['ERROR_CODE'])) {
$pageParams['ERROR_CODE'] = $result['ERROR_CODE'];
return $pageParams;
}
$this->saveSearch($params);
// TODO: return alert_list back in next release
if (array_key_exists('alert_list', $result[$type])) {
unset($result[$type]['alert_list']);
}
if ($type === 'phone') {
unset($result[$type]['valid']);
unset($result[$type]['validation_error']);
}
if ($type === 'email') {
unset($result[$type]['data_breaches']);
}
$pageParams['RESULT'] = [$type => $result[$type]];
return $pageParams;
}
private function validateSearch(array $params, string $enrichmentKey): bool|int {
$errorCode = \Utils\Access::CSRFTokenValid($params, $this->f3);
if ($errorCode) {
return $errorCode;
}
$api = \Utils\Variables::getEnrichtmentApi();
if (!$enrichmentKey || !$api) {
return \Utils\ErrorCodes::ENRICHMENT_API_KEY_DOES_NOT_EXIST;
}
$type = $params['type'] ?? null;
$types = $this->f3->get('AdminManualCheck_form_types');
if (!$type || !array_key_exists($type, $types)) {
return \Utils\ErrorCodes::TYPE_DOES_NOT_EXIST;
}
$search = $params['search'] ?? null;
if (!$search || strlen($search) < 1) {
return \Utils\ErrorCodes::SEARCH_QUERY_DOES_NOT_EXIST;
}
return false;
}
private function saveSearch(array $params): void {
$history = new \Models\ManualCheckHistoryQuery();
$history->add($params);
}
public function getSearchHistory(int $operatorId): ?array {
$model = new \Models\ManualCheckHistory();
return $model->getRecentByOperator($operatorId);
}
}

View File

@@ -0,0 +1,29 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\ManualCheck;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function showIndexPage(): void {
$this->redirectIfUnlogged();
$pageController = new Page();
$this->response = new \Views\Frontend();
$this->response->data = $pageController->getPageParams();
}
}

View File

@@ -0,0 +1,60 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\ManualCheck;
class Page extends \Controllers\Pages\Base {
public $page = 'AdminManualCheck';
public function getPageParams(): array {
$dataController = new Data();
$pageParams = [
'LOAD_AUTOCOMPLETE' => true,
'LOAD_DATATABLE' => true,
'HTML_FILE' => 'admin/manualCheck.html',
'JS' => 'admin_manual_check.js',
];
$currentOperator = $this->f3->get('CURRENT_USER');
$operatorId = $currentOperator->id;
if ($this->isPostRequest()) {
$params = $this->f3->get('POST');
$params['operator'] = $operatorId;
$operationResponse = $dataController->proceedPostRequest($params);
$pageParams = array_merge($pageParams, $operationResponse);
}
$pageParams['HISTORY'] = $dataController->getSearchHistory($operatorId);
return parent::applyPageParams($pageParams);
}
public static function stylizeKey(string $key): string {
$f3 = \Base::instance();
$overwrites = $f3->get('AdminManualCheck_key_overwrites');
if (array_key_exists($key, $overwrites)) {
return $overwrites[$key];
}
if ($key === 'profiles' || $key === 'data_breach') {
$key = sprintf('no_%s', $key);
}
return ucfirst(str_replace('_', ' ', $key));
}
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Payloads\FieldAuditTrail;
class Data extends \Controllers\Base {
public function getList(int $apiKey): array {
$result = [];
$model = new \Models\Grid\Payloads\FieldAuditTrail\Grid($apiKey);
$userId = $this->f3->get('REQUEST.userId');
if (isset($userId) && is_numeric($userId)) {
$result = $model->getDataByUserId($userId);
}
return $result;
}
}

View File

@@ -0,0 +1,27 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Payloads\FieldAuditTrail;
class Navigation extends \Controllers\Base {
use \Traits\ApiKeys;
use \Traits\Navigation;
public function getList(): array {
$apiKey = $this->getCurrentOperatorApiKeyId();
return $apiKey ? (new Data())->getList($apiKey) : [];
}
}

View File

@@ -0,0 +1,58 @@
<?php
/**
* Tirreno ~ Open source user analytics
* Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
*
* Licensed under GNU Affero General Public License version 3 of the or any later version.
* For full copyright and license information, please see the LICENSE
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Tirreno Technologies Sàrl (https://www.tirreno.com)
* @license https://opensource.org/licenses/AGPL-3.0 AGPL License
* @link https://www.tirreno.com Tirreno(tm)
*/
namespace Controllers\Admin\Phones;
class Data extends \Controllers\Base {
public function getList(int $apiKey): array {
$result = [];
$model = new \Models\Grid\Phones\Grid($apiKey);
$userId = $this->f3->get('REQUEST.userId');
if (isset($userId) && is_numeric($userId)) {
$result = $model->getPhonesByUserId($userId);
}
$ids = array_column($result['data'], 'id');
if ($ids) {
$model = new \Models\Phone();
$model->updateTotalsByEntityIds($ids, $apiKey);
$result['data'] = $model->refreshTotals($result['data'], $apiKey);
}
return $result;
}
public function getPhoneDetails(int $apiKey): array {
$params = $this->f3->get('GET');
$id = $params['id'];
$model = new \Models\Phone();
$details = $model->getPhoneDetails($id, $apiKey);
$details['enrichable'] = $this->isEnrichable($apiKey);
$tsColumns = ['created', 'lastseen'];
\Utils\TimeZones::localizeTimestampsForActiveOperator($tsColumns, $details);
return $details;
}
private function isEnrichable(int $apiKey): bool {
$model = new \Models\ApiKeys();
return $model->attributeIsEnrichable('phone', $apiKey);
}
}

Some files were not shown because too many files have changed in this diff Show More