Browse Source

Update code and packages.

pull/137/head
James Cole 3 years ago
parent
commit
4bd0bf3e9b
  1. 236
      .ci/.env.ci
  2. 15
      .ci/phpstan.neon
  3. 33
      .ci/phpstan.sh
  4. 32
      app/Http/Request/ConfigurationPostRequest.php
  5. 21
      app/Http/Request/Request.php
  6. 13
      composer.json
  7. 1531
      composer.lock
  8. 2
      config/database.php
  9. 2
      config/importer.php

236
.ci/.env.ci

@ -0,0 +1,236 @@
#
# Where is Firefly III?
#
# 1) Make sure you ADD http:// or https://
# 2) Make sure you REMOVE any trailing slash from the end of the URL.
# 3) In case of Docker, refer to the internal IP of your Firefly III installation.
#
# This value is not mandatory. But it is very useful.
#
# This variable can be set from a file if you append it with _FILE
#
FIREFLY_III_URL=
#
# Imagine Firefly III can be reached at "http://172.16.0.2:8082" (internal Docker network or something).
# But you have a fancy URL: "https://personal-finances.bill.microsoft.com/"
#
# In those cases, you can overrule the URL so when the data importer links back to Firefly III, it uses the correct URL.
#
# 1) Make sure you ADD http:// or https://
# 2) Make sure you REMOVE any trailing slash from the end of the URL.
#
# IF YOU SET THIS VALUE, YOU MUST ALSO SET THE FIREFLY_III_URL
#
# This variable can be set from a file if you append it with _FILE
#
VANITY_URL=
#
# Set your Firefly III Personal Access Token
# You can find create a Personal Access Token on the /profile page (at the bottom)
#
# - Do not use the "command line token". That's the WRONG one.
# - Do not use "APP_KEY". That's the WRONG one.
#
# This value is not mandatory to set. Instructions will follow if you omit this field.
#
# This variable can be set from a file if you append it with _FILE
#
FIREFLY_III_ACCESS_TOKEN=
#
# You can also use a public client ID. This is available in Firefly III 5.4.0-alpha.3 and higher.
# This is a number (1, 2, 3). If you use the client ID, you can leave the access token empty and vice versa.
#
# This value is not mandatory to set. Instructions will follow if you omit this field.
#
# This variable can be set from a file if you append it with _FILE
#
FIREFLY_III_CLIENT_ID=
#
# Nordigen information.
# The key and ID can be set from a file if you append it with _FILE
#
NORDIGEN_ID=
NORDIGEN_KEY=
NORDIGEN_SANDBOX=false
#
# Spectre information
#
# The ID and secret can be set from a file if you append it with _FILE
SPECTRE_APP_ID=
SPECTRE_SECRET=
#
# Use cache. No need to do this.
#
USE_CACHE=false
#
# If set to true, the data import will not complain about running into duplicates.
# This will give you cleaner import mails if you run regular imports.
#
# Of course, if something goes wrong *because* the transaction is a duplicate you will
# NEVER know unless you start digging in your log files. So be careful with this.
#
IGNORE_DUPLICATE_ERRORS=false
#
# Auto import settings. Due to security constraints, you MUST enable each feature individually.
# You must also set a secret. The secret is used for the web routes.
#
# The auto-import secret must be a string of at least 16 characters.
# Visit this page for inspiration: https://www.random.org/passwords/?num=1&len=16&format=html&rnd=new
#
# Submit it using ?secret=X
#
# This variable can be set from a file if you append it with _FILE
#
AUTO_IMPORT_SECRET=
#
# Is the /autoimport even endpoint enabled?
# By default it's disabled, and the secret alone will not enable it.
#
CAN_POST_AUTOIMPORT=false
#
# Is the /autoupload endpoint enabled?
# By default it's disabled, and the secret alone will not enable it.
#
CAN_POST_FILES=false
#
# Import directory white list. You need to set this before the auto importer will accept a directory to import from.
#
# This variable can be set from a file if you append it with _FILE
#
IMPORT_DIR_WHITELIST=
#
# When you're running Firefly III under a (self-signed) certificate,
# the data importer may have trouble verifying the TLS connection.
#
# You have a few options to make sure the data importer can connect
# to Firefly III:
# - 'true': will verify all certificates. The most secure option and the default.
# - 'file.pem': refer to a file (you must provide it) to your custom root or intermediate certificates.
# - 'false': will verify NO certificates. Not very secure.
VERIFY_TLS_SECURITY=true
#
# If you want, you can set a directory here where the data importer will look for import configurations.
# This is a separate setting from the /import directory that the auto-import uses.
# Setting this variable isn't necessary. The default value is "storage/configurations".
#
# This variable can be set from a file if you append it with _FILE
#
JSON_CONFIGURATION_DIR=
#
# Time out when connecting with Firefly III.
# π*10 seconds is usually fine.
#
CONNECTION_TIMEOUT=31.41
# The following variables can be useful when debugging the application
APP_ENV=local
APP_DEBUG=false
LOG_CHANNEL=stack
# Log level. You can set this from least severe to most severe:
# debug, info, notice, warning, error, critical, alert, emergency
# If you set it to debug your logs will grow large, and fast. If you set it to emergency probably
# nothing will get logged, ever.
LOG_LEVEL=debug
# TRUSTED_PROXIES is a useful variable when using Docker and/or a reverse proxy.
# Set it to ** and reverse proxies work just fine.
TRUSTED_PROXIES=
#
# Time zone
#
TZ=Europe/Amsterdam
#
# Use ASSET_URL when you're running the data importer in a sub-directory.
#
ASSET_URL=
#
# Email settings.
# The data importer can send you a message with all errors, warnings and messages
# after a successful import. This is disabled by default
#
ENABLE_MAIL_REPORT=false
#
# Force Firefly III URL to be secure?
#
#
EXPECT_SECURE_URL=false
# If enabled, define which mailer you want to use.
# Options include: smtp, mailgun, postmark, sendmail, log, array
# Amazon SES is not supported.
# log = drop mails in the logs instead of sending them
# array = debug mailer that does nothing.
MAIL_MAILER=
# where to send the report?
MAIL_DESTINATION=noreply@example.com
# other mail settings
# These variables can be set from a file if you append it with _FILE
MAIL_FROM_ADDRESS=noreply@example.com
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=null
# Extra settings depending on your mail configuration above.
# These variables can be set from a file if you append it with _FILE
MAILGUN_DOMAIN=
MAILGUN_SECRET=
MAILGUN_ENDPOINT=
POSTMARK_TOKEN=
#
# You probably won't need to change these settings.
#
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
IS_EXTERNAL=false
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
# always use quotes
REDIS_DB="0"
REDIS_CACHE_DB="1"
# The only tracker supported is Matomo.
# This is used on the public instance over at https://data-importer.firefly-iii.org
TRACKER_SITE_ID=
TRACKER_URL=
APP_NAME=DataImporter
#
# The APP_URL environment variable is NOT used anywhere.
# Don't bother setting it to fix your reverse proxy problems. It won't help.
# Don't open issues telling me it doesn't help because it's not supposed to.
# Laravel uses this to generate links on the command line, which is a feature the CVS importer does not use.
#
APP_URL=http://localhost

15
.ci/phpstan.neon

@ -0,0 +1,15 @@
includes:
- ../vendor/nunomaduro/larastan/extension.neon
- ../vendor/ergebnis/phpstan-rules/rules.neon
- ../vendor/phpstan/phpstan-deprecation-rules/rules.neon
- ../vendor/phpstan/phpstan-strict-rules/rules.neon
parameters:
paths:
- ../app
- ../database
- ../routes
- ../bootstrap/app.php
# The level 8 is the highest level. original was 5
level: 3

33
.ci/phpstan.sh

@ -0,0 +1,33 @@
#!/usr/bin/env bash
#
# phpstan.sh
# Copyright (c) 2021 james@firefly-iii.org
#
# This file is part of Firefly III (https://github.com/firefly-iii).
#
# 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/>.
#
# Install composer packages
#composer install --no-scripts --no-ansi
# enable test .env file.
cp .ci/.env.ci .env
# Do static code analysis.
# ./vendor/bin/phpstan analyse -c .ci/phpstan.neon --no-progress
./vendor/bin/phpstan analyse -c .ci/phpstan.neon
exit 0

32
app/Http/Request/ConfigurationPostRequest.php

@ -50,9 +50,9 @@ class ConfigurationPostRequest extends Request
{
$result = [
'headers' => $this->convertBoolean($this->get('headers')),
'delimiter' => $this->string('delimiter'),
'date' => $this->string('date'),
'default_account' => $this->integer('default_account'),
'delimiter' => $this->convertToString('delimiter'),
'date' => $this->convertToString('date'),
'default_account' => $this->convertToInteger('default_account'),
'rules' => $this->convertBoolean($this->get('rules')),
'ignore_duplicate_lines' => $this->convertBoolean($this->get('ignore_duplicate_lines')),
'ignore_duplicate_transactions' => $this->convertBoolean($this->get('ignore_duplicate_transactions')),
@ -62,31 +62,31 @@ class ConfigurationPostRequest extends Request
'roles' => [],
'mapping' => [],
'do_mapping' => [],
'flow' => $this->string('flow'),
'flow' => $this->convertToString('flow'),
// duplicate detection:
'duplicate_detection_method' => $this->string('duplicate_detection_method'),
'unique_column_index' => $this->integer('unique_column_index'),
'unique_column_type' => $this->string('unique_column_type'),
'duplicate_detection_method' => $this->convertToString('duplicate_detection_method'),
'unique_column_index' => $this->convertToInteger('unique_column_index'),
'unique_column_type' => $this->convertToString('unique_column_type'),
// spectre values:
'connection' => $this->string('connection'),
'identifier' => $this->string('identifier'),
'connection' => $this->convertToString('connection'),
'identifier' => $this->convertToString('identifier'),
'ignore_spectre_categories' => $this->convertBoolean($this->get('ignore_spectre_categories')),
// nordigen:
'nordigen_country' => $this->string('nordigen_country'),
'nordigen_bank' => $this->string('nordigen_bank'),
'nordigen_max_days' => $this->string('nordigen_max_days'),
'nordigen_requisitions' => json_decode($this->string('nordigen_requisitions'), true) ?? [],
'nordigen_country' => $this->convertToString('nordigen_country'),
'nordigen_bank' => $this->convertToString('nordigen_bank'),
'nordigen_max_days' => $this->convertToString('nordigen_max_days'),
'nordigen_requisitions' => json_decode($this->convertToString('nordigen_requisitions'), true) ?? [],
// nordigen + spectre
'do_import' => $this->get('do_import') ?? [],
'accounts' => $this->get('accounts') ?? [],
'map_all_data' => $this->convertBoolean($this->get('map_all_data')),
'date_range' => $this->string('date_range'),
'date_range_number' => $this->integer('date_range_number'),
'date_range_unit' => $this->string('date_range_unit'),
'date_range' => $this->convertToString('date_range'),
'date_range_number' => $this->convertToInteger('date_range_number'),
'date_range_unit' => $this->convertToString('date_range_unit'),
'date_not_before' => $this->getCarbonDate('date_not_before'),
'date_not_after' => $this->getCarbonDate('date_not_after'),

21
app/Http/Request/Request.php

@ -53,23 +53,6 @@ class Request extends FormRequest
return false;
}
/**
* Return floating value.
*
* @param string $field
*
* @return float|null
*/
public function float(string $field): ?float
{
$res = $this->get($field);
if (null === $res) {
return null;
}
return (float) $res;
}
/**
* Return integer value.
*
@ -77,7 +60,7 @@ class Request extends FormRequest
*
* @return int
*/
public function integer(string $field): int
public function convertToInteger(string $field): int
{
return (int) $this->get($field);
}
@ -145,7 +128,7 @@ class Request extends FormRequest
*
* @return string
*/
public function string(string $field): string
public function convertToString(string $field): string
{
return app('steam')->cleanStringAndNewlines((string) ($this->get($field) ?? ''));
}

13
composer.json

@ -80,20 +80,25 @@
"firefly-iii/api-support-classes": "@dev",
"fruitcake/laravel-cors": "^3.0",
"guzzlehttp/guzzle": "^7.0",
"laravel/framework": "^8.0",
"laravel/framework": "^9.0",
"laravel/tinker": "^2.0",
"league/csv": "9.*",
"rcrowe/twigbridge": "^0.14.0",
"spatie/enum": "^3.10"
},
"require-dev": {
"filp/whoops": "^2.0",
"fakerphp/faker": "^1.4",
"barryvdh/laravel-debugbar": "^3.2",
"barryvdh/laravel-ide-helper": "^2.6",
"ergebnis/phpstan-rules": "^1.0",
"fakerphp/faker": "^1.4",
"filp/whoops": "^2.0",
"laravel/ui": "^3.0",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^5.0",
"nunomaduro/collision": "^6.1",
"nunomaduro/larastan": "^2.0",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-strict-rules": "^1.3",
"phpunit/phpunit": "^9.2",
"roave/security-advisories": "dev-master"
},

1531
composer.lock
File diff suppressed because it is too large
View File

2
config/database.php

@ -99,7 +99,7 @@ return [
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'schema' => 'public',
'search_path' => 'public',
'sslmode' => 'prefer',
],

2
config/importer.php

@ -23,7 +23,7 @@
declare(strict_types=1);
return [
'version' => '0.9.14',
'version' => '0.9.15',
'flows' => ['nordigen', 'spectre', 'file'],
'flow_titles' => [
'file' => 'File',

Loading…
Cancel
Save