A method for dynamic control, at file level, of the integrity of a set of files stored in a persistent memory (11) of a computer (1), said method comprising:
- allocating (52) a first memory space (242, 342, 642M, 642N) in the persistent memory (11) of the computer (1), in which are stored files (251, 301, 303, 304) the integrity of which must be controlled;
- allocating (52) a second memory space (243, 343, 643M, 643N, 643Ma) in the persistent memory of the computer, separate from the first memory space;
- locking to read-only (52), of the first memory space containing the files (251, 301, 303, 304) the integrity of which must be controlled;
- implementing a copy-on-write mechanism with respect to the files (251, 301,303, 304) contained in the first memory space, ensuring the creation of a copy of at least one of said files in the second memory space when the at least one file is modified and the 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 (53) a list, said created list corresponding to a list called denylist (220), of files from the second memory space to be excluded from the integrity control, or a list called allowlist, of files from the second memory space to be included in the integrity control;
- dynamic inspection (55), at predetermined times during the operation of the computer, of the second memory space in order to identify files therein with the exception of the files from the denylist (220) or to identify files therein from the allowlist;
- detecting (56) an integrity violation of a file from among the files 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 (57), executed in response to the detection of an integrity violation of a file from among the files the integrity of which must be controlled, from the first memory space.