mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-01-09 20:11:22 +00:00
Update some code, add security txt file.
This commit is contained in:
@@ -96,7 +96,7 @@ class ReconcileController extends Controller
|
||||
$preFilled = [
|
||||
'date' => $this->repository->getJournalDate($journal, null),
|
||||
'category' => $this->repository->getJournalCategoryName($journal),
|
||||
'tags' => join(',', $journal->tags->pluck('tag')->toArray()),
|
||||
'tags' => implode(',', $journal->tags->pluck('tag')->toArray()),
|
||||
'amount' => $pTransaction->amount,
|
||||
];
|
||||
|
||||
@@ -319,7 +319,7 @@ class ReconcileController extends Controller
|
||||
'category_name' => null,
|
||||
],
|
||||
],
|
||||
'notes' => join(', ', $data['transactions']),
|
||||
'notes' => implode(', ', $data['transactions']),
|
||||
];
|
||||
|
||||
$journal = $repository->store($journalData);
|
||||
|
||||
@@ -76,6 +76,7 @@ class LinkController extends Controller
|
||||
* @param LinkType $linkType
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function delete(Request $request, LinkTypeRepositoryInterface $repository, LinkType $linkType)
|
||||
{
|
||||
@@ -108,6 +109,7 @@ class LinkController extends Controller
|
||||
* @param LinkType $linkType
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function destroy(Request $request, LinkTypeRepositoryInterface $repository, LinkType $linkType)
|
||||
{
|
||||
@@ -126,6 +128,7 @@ class LinkController extends Controller
|
||||
* @param LinkType $linkType
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function edit(Request $request, LinkType $linkType)
|
||||
{
|
||||
@@ -184,6 +187,7 @@ class LinkController extends Controller
|
||||
* @param LinkTypeRepositoryInterface $repository
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function store(LinkTypeFormRequest $request, LinkTypeRepositoryInterface $repository)
|
||||
{
|
||||
@@ -212,6 +216,7 @@ class LinkController extends Controller
|
||||
* @param LinkType $linkType
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function update(LinkTypeFormRequest $request, LinkTypeRepositoryInterface $repository, LinkType $linkType)
|
||||
{
|
||||
|
||||
@@ -61,6 +61,8 @@ class UpdateController extends Controller
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Illuminate\Container\EntryNotFoundException
|
||||
*/
|
||||
public function index()
|
||||
|
||||
@@ -65,6 +65,7 @@ class LoginController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function login(Request $request)
|
||||
@@ -102,6 +103,7 @@ class LoginController extends Controller
|
||||
* @param CookieJar $cookieJar
|
||||
*
|
||||
* @return $this|\Illuminate\Http\RedirectResponse
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function logout(Request $request, CookieJar $cookieJar)
|
||||
{
|
||||
@@ -119,6 +121,7 @@ class LoginController extends Controller
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function showLoginForm(Request $request)
|
||||
{
|
||||
|
||||
@@ -40,6 +40,7 @@ class TwoFactorController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @throws FireflyException
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
@@ -91,6 +92,7 @@ class TwoFactorController extends Controller
|
||||
*
|
||||
* @return mixed
|
||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) // it's unused but the class does some validation.
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function postIndex(TokenFormRequest $request, CookieJar $cookieJar)
|
||||
{
|
||||
|
||||
@@ -97,6 +97,7 @@ class ConfigurationController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function post(Request $request, ImportJob $job)
|
||||
|
||||
@@ -71,7 +71,7 @@ class IndexController extends Controller
|
||||
*/
|
||||
public function create(string $bank)
|
||||
{
|
||||
if (true === !(config(sprintf('import.enabled.%s', $bank)))) {
|
||||
if (true === !config(sprintf('import.enabled.%s', $bank))) {
|
||||
throw new FireflyException(sprintf('Cannot import from "%s" at this time.', $bank)); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ class PrerequisitesController extends Controller
|
||||
*/
|
||||
public function index(string $bank)
|
||||
{
|
||||
if (true === !(config(sprintf('import.enabled.%s', $bank)))) {
|
||||
if (true === !config(sprintf('import.enabled.%s', $bank))) {
|
||||
throw new FireflyException(sprintf('Cannot import from "%s" at this time.', $bank)); // @codeCoverageIgnore
|
||||
}
|
||||
$class = strval(config(sprintf('import.prerequisites.%s', $bank)));
|
||||
@@ -103,13 +103,14 @@ class PrerequisitesController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function post(Request $request, string $bank)
|
||||
{
|
||||
Log::debug(sprintf('Now in postPrerequisites for %s', $bank));
|
||||
|
||||
if (true === !(config(sprintf('import.enabled.%s', $bank)))) {
|
||||
if (true === !config(sprintf('import.enabled.%s', $bank))) {
|
||||
throw new FireflyException(sprintf('Cannot import from "%s" at this time.', $bank)); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
||||
@@ -244,6 +244,15 @@ class BoxController extends Controller
|
||||
if ($currencyId !== 0) {
|
||||
$accountCurrency = $currencyRepos->findNull($currencyId);
|
||||
}
|
||||
|
||||
// if the account is a credit card, subtract the virtual balance from the balance,
|
||||
// to better reflect that this is not money that is actually "yours".
|
||||
$role = (string)$repository->getMetaValue($account, 'accountRole');
|
||||
$virtualBalance = (string)$account->virtual_balance;
|
||||
if ($role === 'ccAsset' && $virtualBalance !== '' && (float)$virtualBalance > 0) {
|
||||
$balance = bcsub($balance, $virtualBalance);
|
||||
}
|
||||
|
||||
if (!isset($netWorth[$accountCurrency->id])) {
|
||||
$netWorth[$accountCurrency->id]['currency'] = $accountCurrency;
|
||||
$netWorth[$accountCurrency->id]['sum'] = '0';
|
||||
|
||||
@@ -35,6 +35,7 @@ use phpseclib\Crypt\RSA;
|
||||
*/
|
||||
class InstallController extends Controller
|
||||
{
|
||||
/** @noinspection MagicMethodsValidityInspection */
|
||||
/**
|
||||
* InstallController constructor.
|
||||
*/
|
||||
@@ -66,7 +67,7 @@ class InstallController extends Controller
|
||||
Passport::keyPath('oauth-private.key'),
|
||||
];
|
||||
|
||||
if ((file_exists($publicKey) || file_exists($privateKey))) {
|
||||
if (file_exists($publicKey) || file_exists($privateKey)) {
|
||||
return response()->json(['OK']);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,8 @@ class AuthenticateTwoFactor
|
||||
* @param array ...$guards
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|mixed
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
* @throws \Illuminate\Container\EntryNotFoundException
|
||||
*/
|
||||
public function handle($request, Closure $next, ...$guards)
|
||||
|
||||
@@ -63,6 +63,7 @@ class Binder
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function handle($request, Closure $next, ...$guards)
|
||||
{
|
||||
|
||||
@@ -39,6 +39,7 @@ class IsDemoUser
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
|
||||
@@ -68,9 +68,9 @@ class AccountFormRequest extends Request
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$accountRoles = join(',', config('firefly.accountRoles'));
|
||||
$types = join(',', array_keys(config('firefly.subTitlesByIdentifier')));
|
||||
$ccPaymentTypes = join(',', array_keys(config('firefly.ccTypes')));
|
||||
$accountRoles = implode(',', config('firefly.accountRoles'));
|
||||
$types = implode(',', array_keys(config('firefly.subTitlesByIdentifier')));
|
||||
$ccPaymentTypes = implode(',', array_keys(config('firefly.ccTypes')));
|
||||
$rules = [
|
||||
'name' => 'required|min:1|uniqueAccountForUser',
|
||||
'openingBalance' => 'numeric|required_with:openingBalanceDate|nullable',
|
||||
|
||||
@@ -40,13 +40,14 @@ class ExportFormRequest extends Request
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
$sessionFirst = clone session('first');
|
||||
$first = $sessionFirst->subDay()->format('Y-m-d');
|
||||
$today = Carbon::create()->addDay()->format('Y-m-d');
|
||||
$formats = join(',', array_keys(config('firefly.export_formats')));
|
||||
$formats = implode(',', array_keys(config('firefly.export_formats')));
|
||||
|
||||
// fixed
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class JournalLinkRequest extends Request
|
||||
$return = [];
|
||||
$linkType = $this->get('link_type');
|
||||
$parts = explode('_', $linkType);
|
||||
$return['link_type_id'] = intval($parts[0]);
|
||||
$return['link_type_id'] = (int)$parts[0];
|
||||
$return['transaction_journal_id'] = $this->integer('link_journal_id');
|
||||
$return['notes'] = strlen($this->string('notes')) > 0 ? $this->string('notes') : '';
|
||||
$return['direction'] = $parts[1];
|
||||
@@ -70,7 +70,7 @@ class JournalLinkRequest extends Request
|
||||
$combinations[] = sprintf('%d_inward', $type->id);
|
||||
$combinations[] = sprintf('%d_outward', $type->id);
|
||||
}
|
||||
$string = join(',', $combinations);
|
||||
$string = implode(',', $combinations);
|
||||
|
||||
// fixed
|
||||
return [
|
||||
|
||||
@@ -30,6 +30,7 @@ use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class CategoryFormRequest.
|
||||
@@ -124,6 +125,7 @@ class ReportFormRequest extends Request
|
||||
$date = new Carbon($parts[1]);
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Exception $e) {
|
||||
Log::error(sprintf('"%s" is not a valid date range.', $range));
|
||||
throw new FireflyException(sprintf('"%s" is not a valid date range.', $range));
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
@@ -170,6 +172,7 @@ class ReportFormRequest extends Request
|
||||
$date = new Carbon($parts[0]);
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Exception $e) {
|
||||
Log::error(sprintf('"%s" is not a valid date range.', $range));
|
||||
throw new FireflyException(sprintf('"%s" is not a valid date range.', $range));
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ class RuleFormRequest extends Request
|
||||
$validActions = array_keys(config('firefly.rule-actions'));
|
||||
|
||||
// some actions require text:
|
||||
$contextActions = join(',', config('firefly.rule-actions-text'));
|
||||
$contextActions = implode(',', config('firefly.rule-actions-text'));
|
||||
|
||||
$titleRule = 'required|between:1,100|uniqueObjectForUser:rules,title';
|
||||
if (null !== $repository->find(intval($this->get('id')))->id) {
|
||||
@@ -82,9 +82,9 @@ class RuleFormRequest extends Request
|
||||
'stop_processing' => 'boolean',
|
||||
'rule_group_id' => 'required|belongsToUser:rule_groups',
|
||||
'trigger' => 'required|in:store-journal,update-journal',
|
||||
'rule-trigger.*' => 'required|in:' . join(',', $validTriggers),
|
||||
'rule-trigger.*' => 'required|in:' . implode(',', $validTriggers),
|
||||
'rule-trigger-value.*' => 'required|min:1|ruleTriggerValue',
|
||||
'rule-action.*' => 'required|in:' . join(',', $validActions),
|
||||
'rule-action.*' => 'required|in:' . implode(',', $validActions),
|
||||
];
|
||||
// since Laravel does not support this stuff yet, here's a trick.
|
||||
for ($i = 0; $i < 10; ++$i) {
|
||||
|
||||
@@ -41,6 +41,7 @@ class SelectTransactionsRequest extends Request
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
|
||||
@@ -154,11 +154,9 @@ class SplitJournalFormRequest extends Request
|
||||
$transactions = $data['transactions'] ?? [];
|
||||
/** @var array $array */
|
||||
foreach ($transactions as $array) {
|
||||
if ($array['destination_id'] !== null && $array['source_id'] !== null) {
|
||||
if ($array['destination_id'] === $array['source_id']) {
|
||||
$validator->errors()->add('journal_source_account_id', trans('validation.source_equals_destination'));
|
||||
$validator->errors()->add('journal_destination_account_id', trans('validation.source_equals_destination'));
|
||||
}
|
||||
if ($array['destination_id'] !== null && $array['source_id'] !== null && $array['destination_id'] === $array['source_id']) {
|
||||
$validator->errors()->add('journal_source_account_id', trans('validation.source_equals_destination'));
|
||||
$validator->errors()->add('journal_destination_account_id', trans('validation.source_equals_destination'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class TestRuleFormRequest extends Request
|
||||
// fixed
|
||||
$validTriggers = array_keys(config('firefly.rule-triggers'));
|
||||
$rules = [
|
||||
'rule-trigger.*' => 'required|min:1|in:' . join(',', $validTriggers),
|
||||
'rule-trigger.*' => 'required|min:1|in:' . implode(',', $validTriggers),
|
||||
'rule-trigger-value.*' => 'required|min:1|ruleTriggerValue',
|
||||
];
|
||||
|
||||
|
||||
@@ -43,10 +43,8 @@ class TokenFormRequest extends Request
|
||||
public function rules()
|
||||
{
|
||||
// fixed
|
||||
$rules = [
|
||||
return [
|
||||
'code' => 'required|2faCode',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user