コード例 #1
0
 def test3_secure_open_directory(self):
     """A directory is tried to be opened without using the O_Directory flag."""
     error = sys.stderr = StringIO()
     directory = b'/etc/'
     self.assertRaises(Exception, secure_open_file, directory, os.O_RDONLY)
     secure_open_file(directory, os.O_DIRECTORY)
     SecureOSFunctions.no_secure_open_warn_once_flag = True
     self.assertTrue(
         error.getvalue() in ['WARNING: SECURITY: No secure open yet due to missing openat in python!\n', ''])
コード例 #2
0
 def test5send_annotated_file_descriptor_invalid_parameters(self):
     """An invalid access is to be performed by using a closed socket."""
     # socket is closed
     fd = secure_open_file(b'/etc/aminer/conf-enabled/Readme.txt', os.O_RDONLY)
     client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
     self.assertRaises(OSError, send_annotated_file_descriptor, client, fd, b'readmeStream',
                       b'You should read these README instructions for better understanding.')
コード例 #3
0
from time import sleep
import socket
import sys
import os
sys.path.append('../../')
sys.path.append('./')
# skipcq: FLK-E402
from aminer.util.SecureOSFunctions import secure_open_file, send_logstream_descriptor

sock_name = '/tmp/test6unixSocket.sock'  # skipcq: BAN-B108
fd = secure_open_file(b'/var/log/syslog', os.O_RDONLY)
sleep(0.5)
client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
client.connect(sock_name)
send_logstream_descriptor(client, fd, b'/var/log/syslog')
コード例 #4
0
from time import sleep
import socket
import sys
import os
sys.path.append('./')
sys.path.append('../../')
# skipcq: FLK-E402
from aminer.util.SecureOSFunctions import secure_open_file, send_annotated_file_descriptor

sock_name = '/tmp/test4unixSocket.sock'
fd = secure_open_file(b'/etc/aminer/conf-enabled/Readme.txt', os.O_RDONLY)
sleep(0.5)
client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
client.connect(sock_name)
send_annotated_file_descriptor(
    client, fd, b'readmeStream',
    b'You should read these README instructions for better understanding.')