A method for dynamic control, at file level, of an integrity of a set of files stored in a persistent memory of a computer, said method comprising:
- allocating a first memory space in the persistent memory of the computer, said first memory space comprising stored files with the integrity of which must be controlled;
- allocating a second memory space in the persistent memory of the computer, separate from the first memory space;
- locking to read-only, of the first memory space containing the stored files with the integrity of which must be controlled;
- implementing a copy-on-write mechanism with respect to the stored files contained in the first memory space, ensuring a creation of a copy of at least one file of said stored files in the second memory space when the at least one file is modified and redirection of all instances of subsequent access to the at least one file to said copy of the at least one file in the second memory space;
- creating a list, said list comprising a denylist, of files from the second memory space to be excluded from the integrity of which must be controlled, or said list comprising an allowlist, of files from the second memory space to be included in the integrity of which must be controlled;
- dynamic inspection, at predetermined times during operation of the computer, of the second memory space in order to identify said files therein with an exception of the files from the denylist or to identify said files therein from the allowlist;
- detecting an integrity violation of a file from among the stored files with the integrity of which must be controlled, stored in the first memory space, if a copy of said file is identified in the second memory space;
- and
- at least one predetermined action, executed in response to the detecting the integrity violation of said file from among the files with the integrity of which must be controlled, from the first memory space.