Giter VIP home page Giter VIP logo

audit-stash's People

Contributors

aceat64 avatar ajibarra avatar amayer5125 avatar arusinowski avatar blamh avatar bmudda avatar bravo-kernel avatar cauancabral avatar cnizzardini avatar dereuromark avatar harikt avatar hridaytaneja avatar jippi avatar lorenzo avatar medero avatar swiffer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

audit-stash's Issues

blacklist does not over-ride default

I'm trying to have the modified field tracked by AuditStash, but specifying a blacklist w/out it will not include changes to modified.

From Model/Table/SomeTable.php

public function initialize(array $config) {
        $this->addBehavior('AuditStash.AuditLog', [
            'blacklist' => ['created']
        ]);
    ...
}

If I remove modified from the blacklist in audit-stash/src/Model/Behavior/AuditLogBehavior.php, however, the field is tracked in Audit Log changes.

audit-stash not working when updating multiple rows together

The plugin works fine with all my tables. But I have a particular function in which the user selects rows with checkboxes, and then changes a specific field to all of them. The table audits contains a fields called "primary_key" which seems not working for such case.

in my Controller, function, I put this:
`$this->request->data;
$data = $this->request->data;

    if($this->request->is(['patch', 'post', 'put'])) 
    {
        $ids = $this->request->data('data.AssetsAssignations.id');
        $room_id = $this->request->data('room_id');

        $this->AssetsAssignations->updateAll(
            ['room_id ' => $room_id ],
            ['id IN' => $ids]
        );

    }`

in my table, I used this:
$this->addBehavior('AuditStash.AuditLog');

Since editing multiple rows is more dangerous, can you help me fix it?

thanks

Multiple index guide incorrect

The README specify that we need to use %s in the configuration to use multiple index.
However, the 2 configurations on it are the same, how should I proceed?

Tests fail on my local

Forked this library to make some changes I need. I ran unit tests without changing code to see if things are in good working order and encountered fatals. It seems this library expects external dependencies to run tests?

PHP version: 7.4 (initially tried on 8.1)
Host: Ubuntu 22.04
Version: master

> vendor/bin/phpunit

EEEEEE.................PHP Fatal error:  Uncaught Elastica\Exception\Connection\HttpException: Couldn't connect to host, Elasticsearch down? in /var/www/personal/audit-stash/vendor/ruflin/elastica/src/Transport/Http.php:186
Stack trace:
#0 /var/www/personal/audit-stash/vendor/ruflin/elastica/src/Request.php(183): Elastica\Transport\Http->exec()
#1 /var/www/personal/audit-stash/vendor/ruflin/elastica/src/Client.php(545): Elastica\Request->send()
#2 /var/www/personal/audit-stash/vendor/ruflin/elastica/src/Client.php(584): Elastica\Client->request()
#3 /var/www/personal/audit-stash/vendor/ruflin/elastica/src/Status.php(163): Elastica\Client->requestEndpoint()
#4 /var/www/personal/audit-stash/vendor/ruflin/elastica/src/Status.php(53): Elastica\Status->refresh()
#5 /var/www/personal/audit-stash/vendor/ruflin/elastica/src/Status.php(66): Elastica\Status->getData()
#6 /var/www/personal/audit-stash/vendor/cakephp/elastic-search/src/Datasource/SchemaCollection.php(51): Elastica\Status->getIndexNames()
#7 /var/www/personal/audit-stash/vendor/cakephp/cakephp/s in /var/www/personal/audit-stash/vendor/ruflin/elastica/src/Transport/Http.php on line 186

Fatal error: Uncaught Elastica\Exception\Connection\HttpException: Couldn't connect to host, Elasticsearch down? in /var/www/personal/audit-stash/vendor/ruflin/elastica/src/Transport/Http.php:186
Stack trace:
#0 /var/www/personal/audit-stash/vendor/ruflin/elastica/src/Request.php(183): Elastica\Transport\Http->exec()
#1 /var/www/personal/audit-stash/vendor/ruflin/elastica/src/Client.php(545): Elastica\Request->send()
#2 /var/www/personal/audit-stash/vendor/ruflin/elastica/src/Client.php(584): Elastica\Client->request()
#3 /var/www/personal/audit-stash/vendor/ruflin/elastica/src/Status.php(163): Elastica\Client->requestEndpoint()
#4 /var/www/personal/audit-stash/vendor/ruflin/elastica/src/Status.php(53): Elastica\Status->refresh()
#5 /var/www/personal/audit-stash/vendor/ruflin/elastica/src/Status.php(66): Elastica\Status->getData()
#6 /var/www/personal/audit-stash/vendor/cakephp/elastic-search/src/Datasource/SchemaCollection.php(51): Elastica\Status->getIndexNames()
#7 /var/www/personal/audit-stash/vendor/cakephp/cakephp/s in /var/www/personal/audit-stash/vendor/ruflin/elastica/src/Transport/Http.php on line 186

Additionally there are deprecation notices:

PHPUnit 8.5.33 by Sebastian Bergmann and contributors.

PHP Deprecated:  You are using the listener based PHPUnit integration. This fixture system is deprecated, and we recommend you upgrade to the extension based PHPUnit integration. See https://book.cakephp.org/4/en/appendices/fixture-upgrade.html
/var/www/personal/audit-stash/vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php, line: 79
You can disable all deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED`. Adding `src/TestSuite/Fixture/FixtureInjector.php` to `Error.ignoredDeprecationPaths` in your `config/app.php` config will mute deprecations from that file only. in /var/www/personal/audit-stash/vendor/cakephp/cakephp/src/Core/functions.php on line 323

Deprecated: You are using the listener based PHPUnit integration. This fixture system is deprecated, and we recommend you upgrade to the extension based PHPUnit integration. See https://book.cakephp.org/4/en/appendices/fixture-upgrade.html
/var/www/personal/audit-stash/vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php, line: 79
You can disable all deprecation warnings by setting `Error.errorLevel` to `E_ALL & ~E_USER_DEPRECATED`. Adding `src/TestSuite/Fixture/FixtureInjector.php` to `Error.ignoredDeprecationPaths` in your `config/app.php` config will mute deprecations from that file only. in /var/www/personal/audit-stash/vendor/cakephp/cakephp/src/Core/functions.php on line 323

Your requirements could not be resolved to an installable set of packages

I'm on CakePHP 3.10 and I'm getting this error when I try to add audit-stash to my project:

- lorenzo/audit-stash[3.0.0, ..., 3.0.2] require cakephp/orm ^4.0 -> found cakephp/orm[4.0.0, ..., 4.2.9] but it conflicts with another require.
- Root composer.json requires lorenzo/audit-stash ^3.0 -> satisfiable by lorenzo/audit-stash[3.0.0, 3.0.1, 3.0.2].

Any ideas?

Exception: No handler for type [string] declared on field [transaction]

string type are deprecate in elasticsearch v6.

I get this error when I try:
./bin/cake elastic_mapping Planillapagos
Exception: No handler for type [string] declared on field [transaction] in [/var/www/apps/hbc/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php, line 174]
2018-05-11 00:36:48 Error: [Elastica\Exception\ResponseException] No handler for type [string] declared on field [transaction] in /var/www/apps/hbc/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php on line 174
Stack Trace:
#0 /var/www/apps/hbc/vendor/ruflin/elastica/lib/Elastica/Request.php(171): Elastica\Transport\Http->exec(Object(Elastica\Request), Array)
#1 /var/www/apps/hbc/vendor/ruflin/elastica/lib/Elastica/Client.php(662): Elastica\Request->send()
#2 /var/www/apps/hbc/vendor/ruflin/elastica/lib/Elastica/Index.php(518): Elastica\Client->request('audit-logs/plan...', 'PUT', Array, Array)
#3 /var/www/apps/hbc/vendor/ruflin/elastica/lib/Elastica/Type.php(519): Elastica\Index->request('audit-logs/plan...', 'PUT', Array, Array)
#4 /var/www/apps/hbc/vendor/ruflin/elastica/lib/Elastica/Type/Mapping.php(272): Elastica\Type->request('planillapagos/_...', 'PUT', Array, Array)
#5 /var/www/apps/hbc/vendor/lorenzo/audit-stash/src/Shell/ElasticMappingShell.php(113): Elastica\Type\Mapping->send()
#6 /var/www/apps/hbc/vendor/cakephp/cakephp/src/Console/Shell.php(507): AuditStash\Shell\ElasticMappingShell->main(Object(App\Model\Table\PlanillapagosTable))
#7 /var/www/apps/hbc/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(230): Cake\Console\Shell->runCommand(Array, true, Array)
#8 /var/www/apps/hbc/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(182): Cake\Console\ShellDispatcher->_dispatch(Array)
#9 /var/www/apps/hbc/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(128): Cake\Console\ShellDispatcher->dispatch(Array)
#10 /var/www/apps/hbc/bin/cake.php(33): Cake\Console\ShellDispatcher::run(Array)
#11 {main}

Inserting stringifiable objects

I use Chronos quite a lot and I'm in the habit of inserting dates using like this $entity->cancelled = Chronos::now() (without ->toDateTimeString()) because during marshalling, they are automatically converted to strings.

I've just realised that it's being audited as a json object string:

(Cake\ORM\Entity)
id 1855
type update
...
original {"cancelled":null}
changed {"cancelled":{"date":"2019-04-23 12:09:18.393806","timezone_type":3,"timezone":"Europe\/London"}}
...
created (Cake\I18n\Time)

You reckon changed properties could be forced into becoming strings in the audit log too to avoid the below? Or are there times when it's useful to have the whole object?

Can't find %s in the configuration guide for daily index

The installation guide for cakephp 3 strongly recommends daily index but there is no difference between the single index and daily index configuration in the app.php as i can't find %s in the configuration guide for daily index.

CakePHP 5 Support

Currently, this plugin requires "cakephp/orm": "^4.0", but the latest version of CakePHP 5 requires `"cakephp/orm": "^5.0". Are there any plans to support CakePHP 5?

Thank you!

Behavior doesn't apply when Table is used in a transactional() query.

It appears that the AuditStash behavior isn't being called when the Table is used as part of a transactional query.

For instance:

$schedules_table->connection()->transactional(function() use ($schedules_table, $schedules) {
    foreach ($schedules as $schedule)
    {
        $schedules_table->save($schedule, ['atomic' => false]);
    }
}

Throws an SQL incorrect syntax error on test

I tried testing my application with audit log fixture, it blows up showing the error below. I made some research and its seems to be coming from the SQL syntax.
cakephp version : 3.5.3

Unable to insert fixture "App\Test\Fixture\AuditLogsFixture" in "StudentsManager\Test\TestCase\Controller\StudentsControllerTest" test case: 
SQLSTATE[HY000]: General error: 1 near "transaction": syntax error in [/var/www/schoolsystem-online/vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureManager.php, line 347]

AuditLogsType.php does not comply with psr-4 autoloading standard.

Deprecation Notice: Class AuditStash\Model\Index\AuditLogsIndex located in plugins/AuditStash/src\Model\Index\AuditLogsType.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in Composer/Autoload/ClassMapGenerator.php:201

for 2 branch

Error when trying to add mapping

Hi

I cannot use the shell to add the mapping to Elasticsearch:

"Fatal error: Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]]) in D:\Xampp\htdocs\ebsst_v4\vendor\ruflin\elastica\lib\Elastica\Exception\ResponseException.php on line 34"

The command Ive used:

"bin\cake elastic_mapping Employees --use-templates"

Can you help please?

Thanks,
Frank

psr-4 autoloading standard warning in composer 1.10

Deprecation Notice: Class AuditStash\Model\Index\AuditLogsIndex located in ./vendor/lorenzo/audit-stash/src\Model\Index\AuditLogsType.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar://composer.phar/src/Composer/Autoload/ClassMapGenerator.php:185

Logging Cascading Deletes

Is there a way to log cascading deletes?
Table Person has many Docarchives...
Dependent is true...

If i delete a dataset from Person it is logged correctly...
but the dependent Docarchives that get deleted too are not logged...

Title change not stored in log

I found that title field on my table not logged in Audit Log. After that I changed my behavior declarations like below:

    $this->addBehavior('AuditStash.AuditLog', [
        'whitelist' => ['title']
    ]);

But still now not stored title change. I am using my own database persister strategies

Setting priority of this behavior

I need to set the priority of this plugin's afterSave callback in order to have it fire after another plugin's similar callback. Any ideas?

Syntax error in 2.0.0 release

There is a syntax error in 2.0.0 release in src/Shell/ElasticMappingShell.php on line #49. Semicolon is missing at the end of line. It looks like it's been fixed in current master, but it's missing in 2.0.0 release

Issue implementing CRUD ElasticLogsIndexAction - Unknown Method "alias"

Looks like ElasticLogsIndexAction::_handle() is passing Cake\ElasticSearch\Query to PaginatorComponent::paginate().

paginate() attempts to define $alias = $object->alias() using the object it is passed but of course fails to do so.

Before defining $alias it does check to see if the object passed is an instance of QueryInterface

if ($object instanceof QueryInterface) {
    $query = $object;
    $object = $query->repository();
}

I am note sure if this is an issue with my implementation of the CRUD action or an issue with the action itself.

cakephp/cakephp @ 3.1.5
cakephp/elastic-search @ 0.3.0
friendsofcake/crud @ 4.2.1
lorenzo/audit-stash @ dev-master

Rename AuditLogsType.php file to AuditLogsIndex.php

AuditLogsType.php file contains AuditLogsIndex class.

Composer complains:

Deprecation Notice: Class AuditStash\Model\Index\AuditLogsIndex located in ./plugins/AuditStash/src/Model/Index/AuditLogsType.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201

Version: 2.1.0

Why doesn't AuditDeleteEvent track the original entity?

The AuditDeleteEvent implements EventInterface but unlike AuditCreateEvent and AuditUpdateEvent, does not extend the BaseEvent class and as such, does not keep track of the original and changed values.

We know that the changed value is meaningless on a delete, but it seems like it should be tracking the original value shouldn't it?

If this were to be added, could it simply be passed to the AuditDeleteEvent::__construct() as an optional (default null) value?

I'd be happy to patch unless there's a specific reason the original entity data is not being tracked on deletes.

Thanks!

Implement JSON field types

It would be nice if this plugin implemented native MySQL JSON field types instead of mediumtext.

Using the plugin with JSON fields, seems to introduce excessive backslash escaping.

Deprecated field type error when running elastic_mapping shell

When running the shell bin/cake elastic_mapping Users --use-templates, I get the following error:

Exception: No handler for type [multi_field] declared on field [password] [reason: Failed to parse mapping [user]: No handler for type [multi_field] declared on field [password]] in [/my-cakephp-app/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php, line 181]
2018-09-07 03:24:56 Error: [Elastica\Exception\ResponseException] No handler for type [multi_field] declared on field [password] [reason: Failed to parse mapping [user]: No handler for type [multi_field] declared on field [password]] in /my-cakephp-app/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php on line 181
Stack Trace:
#0 /my-cakephp-app/vendor/ruflin/elastica/lib/Elastica/Request.php(193): Elastica\Transport\Http->exec(Object(Elastica\Request), Array)
#1 /my-cakephp-app/vendor/ruflin/elastica/lib/Elastica/Client.php(688): Elastica\Request->send()
#2 [internal function]: Elastica\Client->request('_template/templ...', 'PUT', Array)
#3 /my-cakephp-app/vendor/cakephp/elastic-search/src/Datasource/Connection.php(92): call_user_func_array(Array, Array)
#4 /my-cakephp-app/vendor/lorenzo/audit-stash/src/Shell/ElasticMappingShell.php(109): Cake\ElasticSearch\Datasource\Connection->__call('request', Array)
#5 /my-cakephp-app/vendor/cakephp/cakephp/src/Console/Shell.php(532): AuditStash\Shell\ElasticMappingShell->main(Object(Cake\ORM\Table))
#6 /my-cakephp-app/vendor/cakephp/cakephp/src/Console/CommandRunner.php(342): Cake\Console\Shell->runCommand(Array, true)
#7 /my-cakephp-app/vendor/cakephp/cakephp/src/Console/CommandRunner.php(164): Cake\Console\CommandRunner->runShell(Object(AuditStash\Shell\ElasticMappingShell), Array)
#8 /my-cakephp-app/bin/cake.php(28): Cake\Console\CommandRunner->run(Array)
#9 {main}

I have attached user-mapping.txt that contains the json mapping that is generated by the --dry-run option.

I am using lorenzo/audit-stash:2.0.2 and cakephp/elastic-search:2.0.0-RC2

String datetime changes may break custom DateTimeType implementations

In our application we are using a custom Cake\Database\Type\DateTimeType::marshal() that extends the default CakePHP database type. Our implementation basically interprets strings with no timezone information as being in the user's local timezone.

Upgrading to audit-stash 3.0.2 causes timezone issues with the created timestamp in our application. Previously we received a \DateTime object which we handled correctly. Now, due to the changes in #48, we only receive a string Y-m-d H:i:s with no timezone information given, and our application interprets this as the wrong timezone.

I'm not sure if this is expected behavior and our application is simply at fault for interpreting them differently than UTC. But in any case, this looks like a behavior change which we cannot easily work around due to the tz information loss.

Modifying the type check in #48 to handle inherited classes would solve our issue, but I don't know if this breaks the original authors intent:

if (!is_subclass_of(Type::getMap('datetime'), DateTimeType::class)) {

Or maybe this should be configurable behavior. Any ideas on how to proceed here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.