En effet étrange. Historiquement on peut encore avoir des 500 sur certains dépôts, suite à un très vieux incident serveur. Il doit en rester 2 ou 3 dans ce goût car personne n’a de copie à jour de l’époque. Ce cas est donc à la marge.
Pour les cas présents; à mon niveau, ce qui est effectivement pas du tout normal :
Cela semble indépendant de l’état authentifié. Je regarde les journaux pour voir.
L’interface étant un client git avec un cache web cela ne présuppose par de l’état du dépôt à proprement parler.
Hello,
I am experiencing also an issue and it is severe as I have been pulling the ecran_securite.php with a cron job. based on the spip documentation.
As the repository was down with error 500, the ecran_securite then became a html page.
This faulty ecran_securite then broke one of my sites. On visit of the site, users would instead of the site see the html of the broken spip git server, and an alert box: « Failed to load asset files from https://site/assets/js/index.js?v=1.19.2. Please make sure the asset files can be accessed. »
ecran_security es extremely sensitive, and it seems important to change the cronjob to not accept the file unless it comes with a response 200, not 5xx or other.
Perhaps there is another solution? In any case I propose to update the spip documentation on ecran_securite to warn that cronjobs need to avoid issues caused by error 500.
Notes: This cronjob I already improved from a previous one that used wget. Using wget, if there is an error 400, wget will overwrite the ecran_securite file with an empty file. This is why I switched to curl. Curl however will still accept response code 5XX and place a potentially faulty file on the server.
What is the recommended cronjob to update ecran_securite?
In my opinion, the cronjob should be such that
It will not replace an existing ecran_securite.php file if there is an error 404
→ ecran_securite.php had an URL change I think about 2 years ago. It took some time for many devs to notice that and update a new file. In the meantime, my cron simply deleted the file I had there, leaving the sites completely unprotected, as opposed to simply not updating the file that was previously there. This problem was there with a wget-based cronjob.
It will not replace an existing ecran_securite.php file if there is an error 5XX
→ This is important because of the recent experience I had with curl and gitlab.
I currently have this: curl https://git.spip.net/spip-contrib-outils/securite/raw/branch/master/ecran_securite.php --output /var/www/html/config/ecran_securite.php
However, it does not satisfy point (2). When the gitlab went down, ecran_securite.php was replaced with the html that gitlab provided, making lots of sites look like an error page, and also essentially disabling the ecran_securite.php file (as contents were replaced). I think it is because gitlab showed an error 5XX, but it did not submit this with a proper header.
Whatever it is, the URL on which ecran_securite.php file is hosted is quite critical and I think the cronjob should have some redundancy built-in.
Yes you’ve understood correctly. We us blob content from api to retrieve some extra data as hash fingerprint content.
This hash is generated from git hash-object command.
Following previous code you could do also git hash-object "${ecran_securite_file_path}" and compare hash.
In this case you must have an other source to compare fingerprint.
As API provide all content with one query , I prefer to use it to calculate local hash and compare them
It seems with the migration of spip code to gitlab yet again the URL of the ecran_securite file has changed.
This used to work: curl -f https://git.spip.net/spip-contrib-outils/securite/raw/branch/master/ecran_securite.php -o /var/www/html/config/ecran_securite.php
But after the migration, the URL of ecran_securite has slightly changed.
Another option (as adjusted above for future changes of this URL) is to add to the curl line the option -L
curl -L
So that the redirect is followed. Without it, it will result in an ecran_securite with the following contents, which are then included to every spip page.
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.22.1</center>
</body>
</html>
And as it is I am not sure how this approach would need to be modified:
This seems to be the best approach to prevent faulty ecran_securite.php files from being installed by cron.
I think a proper documentation should be provided on the ecran_securite page to use curl -L. There should also be an way to not complete the download when there is an error 5x, 4x, 3x, which has been an issue before (5xx error page that was shown but without a 5xx header, hence the file was still downloaded).