NineSec Team Shell
Server IP : 184.107.3.203  /  Your IP : 216.73.216.51
Web Server : Apache
System : Linux dedicated2.avenfashion.com.ph 4.18.0-553.40.1.el8_10.x86_64 #1 SMP Mon Feb 10 12:11:18 EST 2025 x86_64
User : adminteladeoro ( 1015)
PHP Version : 8.2.28
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /usr/lib/python3.6/site-packages/sos/upload/__pycache__/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //usr/lib/python3.6/site-packages/sos/upload/__pycache__/__init__.cpython-36.pyc
3

��Zhn3�@sXddlZddlZddlZddlZddlmZddlmZddlm	Z	Gdd�de�Z
dS)�N)�SoSComponent)�_sos)�__version__cs�eZdZdZdZdddddddddddddddddd�Zd#�fd	d
�	Zedd��Zed
d��Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zedd��Zedd��Zedd��Zdd �Zd!d"�Z�ZS)$�	SoSUploadz�
    This class is designed to upload files to a distribution
    defined location. These files can be either sos reports,
    sos collections, or other kind of files like: vmcores,
    application cores, logs, etc.

    z9Upload a file to a user or policy defined remote location�FN�autozhttps://s3.amazonaws.com)�upload_file�case_id�low_priorityZ
upload_url�upload_directoryZupload_userZupload_passZ
upload_methodZupload_no_ssl_verifyZupload_protocolZupload_s3_endpointZupload_s3_regionZupload_s3_bucketZupload_s3_access_keyZupload_s3_secret_keyZupload_s3_object_prefix�
upload_targetcs~|st�j|||�d|_nN|d|_|d|_|d|_||_||_||_||_	t
jd�|_d|_||_
|j�|_d|_dS)NTZoptions�policy�manifestZsos_uiF)�super�__init__�from_cmdline�optsr
r�parser�cmdline�argsZ_upload_file�loggingZ	getLogger�ui_log�archive�load_upload_targets�upload_targetsr)�selfrrrZin_placeZhook_commonsr)�	__class__��/usr/lib/python3.6/__init__.pyr4s



zSoSUpload.__init__cCs:d|_|jdd�}|jdddd�|jdd	d
dd�|jd
ddd�|jdddd�|jdddd�|jdd	ddd�|jdddd�|jdddd�|jdddd�|jdddd�|jddd d�|jd!dd"d�|jd#d$d$d%d&gd'd(�|jd)d$d$d*d+d,d-gd.d(�|jd/d0d1d2d3�|jd4d5d6d7d8d5gd9d(�dS):Nzsos upload FILE [options]zUpload Optionsz.These options control how upload manages filesr�FILEzThe file or archive to upload)�metavar�helpz	--case-idZstorer	zspecify case identifier)�action�destr!z--upload-urlz&Upload the archive to specified server)�defaultr!z
--upload-userzUsername to authenticate withz
--upload-passzPassword to authenticate withz--upload-directoryrz$Specify upload directory for archivez--upload-s3-endpointz#Endpoint to upload to for S3 bucketz--upload-s3-regionz!Region to upload to for S3 bucketz--upload-s3-bucketz"Name of the S3 bucket to upload toz--upload-s3-access-keyzAccess key for the S3 bucketz--upload-s3-secret-keyzSecret key for the S3 bucketz--upload-s3-object-prefixzPrefix for the S3 object/keyz--upload-methodrZputZpostz HTTP method to use for uploading)r$�choicesr!z--upload-protocolZhttpsZftpZsftpZs3z$Manually specify the upload protocolz--upload-no-ssl-verifyF�
store_truez'Disable SSL verification for upload url)r$r"r!z--upload-target�localZredhatZ	canonical�genericzmManually specify vendor-specific target for uploads. Supported options are:
redhat, canonical, generic, local)ZusageZadd_argument_group�add_argument)�clsrZ
upload_grprrr�add_parser_optionsLsX
zSoSUpload.add_parser_optionscCs|jd�|jd�dS)NzSoS Upload Detailed Helpz�The upload command is designed to upload already existing sos reports, as well as other files like logs and vmcores to a distribution specific location.)Z	set_titleZadd_text)r*Zsectionrrr�display_help�s
zSoSUpload.display_helpcCs�d}|jjdt�d��|j|�}|jj|�d}|jjs�yt|�|jjd�WnLtk
rr|jdd�Yn.t	k
r�}z|j|d�WYd	d	}~XnXd	S)
zmPrint the intro message and prompts for a case ID if one is not
        provided on the command line
        a}This utility is used to upload files to a target location based either on a command line option or detecting the local distribution.

The archive to be uploaded may contain data considered sensitive and its content should be reviewed by the originating organization before being passed to any third party.

No configuration changes will be made to the system running this utility.
z
sos upload (version �)z,
Press ENTER to continue, or CTRL-C to quit
rzExiting on user cancel��N)
r�inforZ_fmt_msgrZbatch�input�KeyboardInterrupt�_exit�	Exception)rZ
disclaimerZ	intro_msg�prompt�errr�intro�s
zSoSUpload.introcCs|j|j|jj|jjd�S)N)�cmdlineoptsr
r	r)rr
r	r)rrrr�get_commons�szSoSUpload.get_commonscCs
||_dS)zMSet common host data for the Upload targets
            to reference
        N)�commons)rr:rrr�set_commons�szSoSUpload.set_commonscCs�t|jj��}xP|jj�D]B}|j|�|j�r|jj}|jjd|�d��||_	|j
�|_qW|j	s~|jd|_	|j	j
�|_|jjd|j���dS)aThis sets the upload target and loads that target's options.

        If no upload target is matched and no target is provided by
        the user, then we abort.

        If an upload target is provided in the command line,
        this will not run.
        zInstallation matches z, checking for upload targetsr(zUpload target set to N)
�listr�values�removeZcheck_distributionr�__name__r�debugr�nameZupload_namer0)rZchecksrZcnamerrr�determine_upload_target�s	
z!SoSUpload.determine_upload_targetcCs\ddl}i}xJ|j|jjd�D]6}|d|j|j|jd�}|j|j��|||j	�<qW|S)zELoads all upload targets supported by the local installation
        rN�targetsr/)rrr)
Zsos.upload.targets�
_load_modulesZuploadrCrrrr;r9Z
get_target_id)r�sosZsupported_upload_tgtsrZtarget_classrrrr�s
zSoSUpload.load_upload_targetscCs6g}x,|jD]"}tjj|�r|j|j||��qW|S)zHelper to import upload targets)�__path__�os�path�isdir�extend�_find_modules_in_path)r*�packageZsubmod�modulesrHrrrrD�s
zSoSUpload._load_modulescCsrg}tjj|�rnx\ttj|��D]J}|jd�s0q d|kr:q tjj|�\}}d|�d|��}|j|j|��q W|S)aUGiven a path and a module name, find everything that can be imported
        and then import it

            path - the filesystem path of the package
            modulename - the name of the module in the package

        E.G. a path of 'targets', and a modulename of 'redhat' equates to
        importing sos.upload.targets.redhat
        z.py�__zsos.upload.�.)	rGrH�exists�sorted�listdir�endswith�splitextrJ�_import_modules)r*rHZ
modulenamerMZpyfileZfname�_�modnamerrrrK�s
zSoSUpload._find_modules_in_pathcCs�|jd�d}yt|t�t�|g�}Wn&tk
rL}z
|�WYdd}~XnXtj|tj�}x&|j�D]}|dd	krf|j	|�qfW|S)
z/Import and return all found classes in a modulerO�Nr�DeviceAuthorizationClass�Upload�
RHELPolicy�UbuntuPolicy)rYrZr[r\)
�split�
__import__�globals�locals�ImportError�inspectZ
getmembersZisclass�copyr>)r*rWZmod_short_name�moduler6rM�modrrrrU�szSoSUpload._import_modulescCs(|j�|_|jd}|jr$|jj�dS)Nr8)r9r:r
r
Z_configure_low_priority)r�cmdline_optsrrr�pre_works

zSoSUpload.pre_workcCs�|j�|jr2|j�|jj|_|jj|jd�|_|jj	}|rT|dkrT|j
||_	n|j�|j	sx|jj
d�tjd�|j	j|j��y�tj|j�jdk�r<tjj|j��r"y,|j	j|j�|jjtd|j�d���WnDtk
�r}z&|jj
td|����tjd�WYdd}~XnXn|jj
t|j�d	���n|jj
td|j�d
���WnDtk
�r�}z&|jj
td|j�d|�d
���WYdd}~XnXdS)N)rfr'z|No upload target set via command line options or autodetected.
Please specify one using the option --upload-target.
Exiting.r/rzFile z uploaded successfullyzUpload attempt failed: z is not a file.z
 is empty.zCannot upload z: � )rgrr7rrrr
Zprompt_for_case_idZcaseidrrrBr�error�sys�exitr9rG�stat�st_sizerH�isfileZupload_archiver0rVr4)rZcmdline_target�errr6rrr�executes:

zSoSUpload.execute)NNNFNN)r?�
__module__�__qualname__�__doc__ZdescZarg_defaultsr�classmethodr+r,r7r9r;rBrrDrKrUrgrp�
__classcell__rr)rrrsB5
	r)rGrjrrbZ
sos.componentrrErrVrrrrrr�<module>s

NineSec Team - 2022