You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please consider adding some form of full file encryption (e.g.: Mcrypt?) for the stored JSON files.
Also, please consider adding some form of user authentication (a nice to have).
Keep up the good work!
@adrianvoica It seems like Mcrypt is removed in in PHP 7.2 and introduced Sodium. Sodium is not available in old versions of PHP including 7.1!
Do you have any thoughts/opinion on this?
@rakibtg Well, I am not talking about an actual implementation of a certain algorithm, I am just saying there could be placeholder method (custom hook) that, when present, will encode / decode the data right before writing / after reading from the actual files (based on the user's preference of an algorithm, either an established one or a custom built one). Same goes for authentication. If these 2 "issues" are tackled, I think SleekDB could really take off, since it will have everything required for building rapid JSON-based RESTful APIs. Cheers!
@adrianvoica It seems like Mcrypt is removed in in PHP 7.2 and introduced Sodium. Sodium is not available in old versions of PHP including 7.1!
Do you have any thoughts/opinion on this?
we can make it only for the supported version of PHP
But we would need to add the following to composer.json:
{
"require": {
"ext-openssl": "*",
"defuse/php-encryption": "^2.0"
},
"suggest": {
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
},
}
this is just a thought since we are talking about flat file system and thus given would be tables would be the files or table wold be individual folder with files as entry points. either ways. just encrypt with openssl with key provided by user. us the key to read write individual files, which ever the case may be. I am taking hint from how larvel uses key to encrypt session and cookies and becomes very handy use case on shared hosting.
@Timu57 you caught my gist very nicely and was precisely the larvel repo I had in mind. you are on a right track there is encryption on normal. there is normal+salt+key.
I had in my project used something of similar i.e. suppose json is flat file with bunch of strings (eventually this what it really is). bin-dex it in to alphanumeric characters, Then hash_hmac with secret and then prepend has_hmac and length of charters to the string in following format.
hash_hmac:charaterlength of bin-hex:bin-hex e.g. asdasd23423sda34:10:2sds2545ss
do keep in mind hash_mac would come in fixed string length based on what ever encryption base you choose.
when getting explode : so we get
[ 0 => asdasd23423sda34,
1 =>10
2 =>2sds2545ss
]
quick logic
if (strlen(a[2]) !==a[1] ) run exception;
if (!decryt) run exception;
else do what ever you want.
so given from above suppose we use false as default aka no encryption we can still use the character count mechanism to keep a bay wandering fid bits who may tinker with code a) is not straight off human readable b) it needs some form of processing to be ready for some thing to be done on it else its just bunch of characters c) third it would maintain some from security measure in file or system.
This is my fantasised vision going forward.
Reality is intention is not to make something bullet proof but enough strong to take the shock. if there are other mechanism watching on then system can capture on that 1-2 millisecond buffer it gets. I had custom exception played into mix. If such and such occurs custom exception triggers. you can send an email, set tracking cookie, block IP and what ever else not.
Its two part game one is before the fact and one is after the fact with lots of what ifs in it. what happens when trigger occurs, what happens after the trigger, what happens to resources that depend on resources not offered because trigger occurred - fallback,
Activity
[-]Encrpytion and authentication[/-][+]Encryption and authentication[/+]rakibtg commentedon Feb 22, 2020
@adrianvoica It seems like Mcrypt is removed in in PHP 7.2 and introduced Sodium. Sodium is not available in old versions of PHP including 7.1!
Do you have any thoughts/opinion on this?
vascanera commentedon Feb 23, 2020
@rakibtg Well, I am not talking about an actual implementation of a certain algorithm, I am just saying there could be placeholder method (custom hook) that, when present, will encode / decode the data right before writing / after reading from the actual files (based on the user's preference of an algorithm, either an established one or a custom built one). Same goes for authentication. If these 2 "issues" are tackled, I think SleekDB could really take off, since it will have everything required for building rapid JSON-based RESTful APIs. Cheers!
rakibtg commentedon Feb 26, 2020
@684102 Sure! Send a PR I will check your implementation.. Any contributions are always welcome :)
REDAL commentedon Feb 19, 2021
we can make it only for the supported version of PHP
Timu57 commentedon Feb 22, 2021
We could use the following project to implement encryption instead of reinventing the wheel:
https://github.com/defuse/php-encryption
The dependency graph does not look bad too.
https://github.com/defuse/php-encryption/network/dependencies
But we would need to add the following to composer.json:
{ "require": { "ext-openssl": "*", "defuse/php-encryption": "^2.0" }, "suggest": { "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." }, }TheSyedKazmi commentedon Feb 24, 2021
this is just a thought since we are talking about flat file system and thus given would be tables would be the files or table wold be individual folder with files as entry points. either ways. just encrypt with openssl with key provided by user. us the key to read write individual files, which ever the case may be. I am taking hint from how larvel uses key to encrypt session and cookies and becomes very handy use case on shared hosting.
Timu57 commentedon Feb 25, 2021
@sk-pro-cloud I am sorry but I did not understand what you meant? What would be handy?
Timu57 commentedon Feb 25, 2021
https://github.com/illuminate/encryption
The implementation of encryption in laravel is very interesting and simple.. Could that be something for us?
rakibtg commentedon Feb 25, 2021
@Timu57 In my opinion we should go for https://github.com/illuminate/encryption/ :) Great find btw!
Timu57 commentedon Feb 26, 2021
Encryption modes
I think when implementing encryption we should implement it with 3 modes.
How will SleekDB know which mode to use?
Solution ideas:
New Store method
To retrieve the Encrypter object we could implement one new method to the Store class.
Encrypter methods
Probably we could implement two new methods for the users to work with encryption:
setSettings()
Parameters
$encryptionSetting
falseno encryption will be used (and the settings will be deleted if exist)truethe whole document will be encrypted (except the _id)arrayit has to contain all the fields to encrypt (all fields not included will not be encrypted)Encrypt/Decrypt all documents
For the use case that someone wants to use that feature on an existing database we could / should also provide the following two methods:
encryptAllDocuments()
Uses the current settings to encrypt all documents.
decryptAllDocuments()
Uses the current settings to decrypt all documents.
Other Solutions?!
I am sure we can come up with a more convenient solution than my quick idea. Let us discuss and let us hear your ideas!
TheSyedKazmi commentedon Mar 11, 2021
@Timu57 you caught my gist very nicely and was precisely the larvel repo I had in mind. you are on a right track there is encryption on normal. there is normal+salt+key.
Now there might be cases were one does not need to the whole razmataz of encryption just that file is tinkered with e.g. how Opis if signing files https://opis.io/closure/3.x/security.html. One could adopt the idea of https://opis.io/closure/3.x/security.html#custom-security-providers concept into mix.
I had in my project used something of similar i.e. suppose json is flat file with bunch of strings (eventually this what it really is). bin-dex it in to alphanumeric characters, Then hash_hmac with secret and then prepend has_hmac and length of charters to the string in following format.
hash_hmac:charaterlength of bin-hex:bin-hex e.g. asdasd23423sda34:10:2sds2545ss
do keep in mind hash_mac would come in fixed string length based on what ever encryption base you choose.
when getting explode : so we get
[ 0 => asdasd23423sda34,
1 =>10
2 =>2sds2545ss
]
quick logic
if (strlen(a[2]) !==a[1] ) run exception;
if (!decryt) run exception;
else do what ever you want.
so given from above suppose we use false as default aka no encryption we can still use the character count mechanism to keep a bay wandering fid bits who may tinker with code a) is not straight off human readable b) it needs some form of processing to be ready for some thing to be done on it else its just bunch of characters c) third it would maintain some from security measure in file or system.
This is my fantasised vision going forward.
Reality is intention is not to make something bullet proof but enough strong to take the shock. if there are other mechanism watching on then system can capture on that 1-2 millisecond buffer it gets. I had custom exception played into mix. If such and such occurs custom exception triggers. you can send an email, set tracking cookie, block IP and what ever else not.
Its two part game one is before the fact and one is after the fact with lots of what ifs in it. what happens when trigger occurs, what happens after the trigger, what happens to resources that depend on resources not offered because trigger occurred - fallback,
bespired commentedon Jul 12, 2021
What exactly are you trying to accomplish here?
Seems to me all the code needed to decrypt the stored files are right here where the files are ...
Or am I missing something?
Plus: Finding stuff in encrypted files can be very slow.
mitmelon commentedon May 15, 2022
This is the most efficient way of doing this... But this feature request has been over a year now and yet nothing has been done to implement this...
I think it's best if developers implement this themselves...