annotate OrthancServer/Resources/PreventProtobufDirectoryLeaks.py @ 5414:d5c15e9a63dd

more verbose error
author Alain Mazy <am@osimis.io>
date Wed, 08 Nov 2023 16:02:58 +0100
parents 165b67c02927
children 48b8dae6dc77
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5357
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 #!/usr/bin/python
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 # Orthanc - A Lightweight, RESTful DICOM Store
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 # Department, University Hospital of Liege, Belgium
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 # Copyright (C) 2017-2023 Osimis S.A., Belgium
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 # Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 #
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 # This program is free software: you can redistribute it and/or
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 # modify it under the terms of the GNU General Public License as
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 # published by the Free Software Foundation, either version 3 of the
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 # License, or (at your option) any later version.
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 #
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 # This program is distributed in the hope that it will be useful, but
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 # General Public License for more details.
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 #
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 # You should have received a copy of the GNU General Public License
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 import sys
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 if len(sys.argv) != 2:
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 raise Exception('Bad number of arguments in %s' % sys.argv[0])
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 with open(sys.argv[1], 'r') as f:
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 s = f.read()
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 s = s.replace('__FILE__', '__ORTHANC_FILE__')
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 s = """
5360
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5357
diff changeset
34 #if !defined(__ORTHANC_FILE__)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5357
diff changeset
35 # define __ORTHANC_FILE__ __FILE__
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5357
diff changeset
36 #endif
5357
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 """ + s
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 with open(sys.argv[1], 'w') as f:
fddb5d8d0021 Prevent the leak of the full path of the source files in the binaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 f.write(s)