Best Python code snippet using fMBT_python
upload-content.vue.d.ts
Source:upload-content.vue.d.ts  
1import type { UploadFile, UploadRawFile } from './upload';2declare const _default: import("vue").DefineComponent<{3    readonly beforeUpload: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>) | (() => (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>) | {4        (): (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>;5        new (): any;6        readonly prototype: any;7    } | ((new (...args: any[]) => (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>) | (() => (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>) | {8        (): (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>;9        new (): any;10        readonly prototype: any;11    })[], unknown, unknown, () => void, boolean>;12    readonly onRemove: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void) | (() => (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void) | {13        (): (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void;14        new (): any;15        readonly prototype: any;16    } | ((new (...args: any[]) => (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void) | (() => (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void) | {17        (): (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void;18        new (): any;19        readonly prototype: any;20    })[], unknown, unknown, () => void, boolean>;21    readonly onStart: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (rawFile: UploadRawFile) => void) | (() => (rawFile: UploadRawFile) => void) | {22        (): (rawFile: UploadRawFile) => void;23        new (): any;24        readonly prototype: any;25    } | ((new (...args: any[]) => (rawFile: UploadRawFile) => void) | (() => (rawFile: UploadRawFile) => void) | {26        (): (rawFile: UploadRawFile) => void;27        new (): any;28        readonly prototype: any;29    })[], unknown, unknown, () => void, boolean>;30    readonly onSuccess: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (response: any, rawFile: UploadRawFile) => unknown) | (() => (response: any, rawFile: UploadRawFile) => unknown) | {31        (): (response: any, rawFile: UploadRawFile) => unknown;32        new (): any;33        readonly prototype: any;34    } | ((new (...args: any[]) => (response: any, rawFile: UploadRawFile) => unknown) | (() => (response: any, rawFile: UploadRawFile) => unknown) | {35        (): (response: any, rawFile: UploadRawFile) => unknown;36        new (): any;37        readonly prototype: any;38    })[], unknown, unknown, () => void, boolean>;39    readonly onProgress: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (evt: import("./upload").UploadProgressEvent, rawFile: UploadRawFile) => void) | (() => (evt: import("./upload").UploadProgressEvent, rawFile: UploadRawFile) => void) | {40        (): (evt: import("./upload").UploadProgressEvent, rawFile: UploadRawFile) => void;41        new (): any;42        readonly prototype: any;43    } | ((new (...args: any[]) => (evt: import("./upload").UploadProgressEvent, rawFile: UploadRawFile) => void) | (() => (evt: import("./upload").UploadProgressEvent, rawFile: UploadRawFile) => void) | {44        (): (evt: import("./upload").UploadProgressEvent, rawFile: UploadRawFile) => void;45        new (): any;46        readonly prototype: any;47    })[], unknown, unknown, () => void, boolean>;48    readonly onError: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (err: import("./ajax").UploadAjaxError, rawFile: UploadRawFile) => void) | (() => (err: import("./ajax").UploadAjaxError, rawFile: UploadRawFile) => void) | {49        (): (err: import("./ajax").UploadAjaxError, rawFile: UploadRawFile) => void;50        new (): any;51        readonly prototype: any;52    } | ((new (...args: any[]) => (err: import("./ajax").UploadAjaxError, rawFile: UploadRawFile) => void) | (() => (err: import("./ajax").UploadAjaxError, rawFile: UploadRawFile) => void) | {53        (): (err: import("./ajax").UploadAjaxError, rawFile: UploadRawFile) => void;54        new (): any;55        readonly prototype: any;56    })[], unknown, unknown, () => void, boolean>;57    readonly onExceed: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void) | (() => (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void) | {58        (): (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void;59        new (): any;60        readonly prototype: any;61    } | ((new (...args: any[]) => (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void) | (() => (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void) | {62        (): (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void;63        new (): any;64        readonly prototype: any;65    })[], unknown, unknown, () => void, boolean>;66    readonly action: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "#", boolean>;67    readonly headers: {68        readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => Record<string, any> | Headers) | (() => Record<string, any> | Headers) | ((new (...args: any[]) => Record<string, any> | Headers) | (() => Record<string, any> | Headers))[], unknown, unknown>>;69        readonly required: false;70        readonly validator: ((val: unknown) => boolean) | undefined;71        __epPropKey: true;72    };73    readonly method: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "post", boolean>;74    readonly data: import("element-plus/es/utils").EpPropFinalized<ObjectConstructor, unknown, unknown, () => import("element-plus/es/utils").Mutable<{}>, boolean>;75    readonly multiple: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, false, boolean>;76    readonly name: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "file", boolean>;77    readonly drag: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, false, boolean>;78    readonly withCredentials: BooleanConstructor;79    readonly showFileList: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;80    readonly accept: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;81    readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "select", boolean>;82    readonly fileList: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("./upload").UploadUserFile[]) | (() => import("./upload").UploadUserFile[]) | ((new (...args: any[]) => import("./upload").UploadUserFile[]) | (() => import("./upload").UploadUserFile[]))[], unknown, unknown, () => [], boolean>;83    readonly autoUpload: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;84    readonly listType: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "text" | "picture" | "picture-card", unknown, "text", boolean>;85    readonly httpRequest: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("./upload").UploadRequestHandler) | (() => import("./upload").UploadRequestHandler) | {86        (): import("./upload").UploadRequestHandler;87        new (): any;88        readonly prototype: any;89    } | ((new (...args: any[]) => import("./upload").UploadRequestHandler) | (() => import("./upload").UploadRequestHandler) | {90        (): import("./upload").UploadRequestHandler;91        new (): any;92        readonly prototype: any;93    })[], unknown, unknown, import("./upload").UploadRequestHandler, boolean>;94    readonly disabled: BooleanConstructor;95    readonly limit: NumberConstructor;96}, {97    props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{98        readonly beforeUpload: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>) | (() => (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>) | {99            (): (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>;100            new (): any;101            readonly prototype: any;102        } | ((new (...args: any[]) => (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>) | (() => (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>) | {103            (): (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>;104            new (): any;105            readonly prototype: any;106        })[], unknown, unknown, () => void, boolean>;107        readonly onRemove: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void) | (() => (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void) | {108            (): (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void;109            new (): any;110            readonly prototype: any;111        } | ((new (...args: any[]) => (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void) | (() => (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void) | {112            (): (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void;113            new (): any;114            readonly prototype: any;115        })[], unknown, unknown, () => void, boolean>;116        readonly onStart: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (rawFile: UploadRawFile) => void) | (() => (rawFile: UploadRawFile) => void) | {117            (): (rawFile: UploadRawFile) => void;118            new (): any;119            readonly prototype: any;120        } | ((new (...args: any[]) => (rawFile: UploadRawFile) => void) | (() => (rawFile: UploadRawFile) => void) | {121            (): (rawFile: UploadRawFile) => void;122            new (): any;123            readonly prototype: any;124        })[], unknown, unknown, () => void, boolean>;125        readonly onSuccess: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (response: any, rawFile: UploadRawFile) => unknown) | (() => (response: any, rawFile: UploadRawFile) => unknown) | {126            (): (response: any, rawFile: UploadRawFile) => unknown;127            new (): any;128            readonly prototype: any;129        } | ((new (...args: any[]) => (response: any, rawFile: UploadRawFile) => unknown) | (() => (response: any, rawFile: UploadRawFile) => unknown) | {130            (): (response: any, rawFile: UploadRawFile) => unknown;131            new (): any;132            readonly prototype: any;133        })[], unknown, unknown, () => void, boolean>;134        readonly onProgress: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (evt: import("./upload").UploadProgressEvent, rawFile: UploadRawFile) => void) | (() => (evt: import("./upload").UploadProgressEvent, rawFile: UploadRawFile) => void) | {135            (): (evt: import("./upload").UploadProgressEvent, rawFile: UploadRawFile) => void;136            new (): any;137            readonly prototype: any;138        } | ((new (...args: any[]) => (evt: import("./upload").UploadProgressEvent, rawFile: UploadRawFile) => void) | (() => (evt: import("./upload").UploadProgressEvent, rawFile: UploadRawFile) => void) | {139            (): (evt: import("./upload").UploadProgressEvent, rawFile: UploadRawFile) => void;140            new (): any;141            readonly prototype: any;142        })[], unknown, unknown, () => void, boolean>;143        readonly onError: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (err: import("./ajax").UploadAjaxError, rawFile: UploadRawFile) => void) | (() => (err: import("./ajax").UploadAjaxError, rawFile: UploadRawFile) => void) | {144            (): (err: import("./ajax").UploadAjaxError, rawFile: UploadRawFile) => void;145            new (): any;146            readonly prototype: any;147        } | ((new (...args: any[]) => (err: import("./ajax").UploadAjaxError, rawFile: UploadRawFile) => void) | (() => (err: import("./ajax").UploadAjaxError, rawFile: UploadRawFile) => void) | {148            (): (err: import("./ajax").UploadAjaxError, rawFile: UploadRawFile) => void;149            new (): any;150            readonly prototype: any;151        })[], unknown, unknown, () => void, boolean>;152        readonly onExceed: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void) | (() => (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void) | {153            (): (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void;154            new (): any;155            readonly prototype: any;156        } | ((new (...args: any[]) => (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void) | (() => (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void) | {157            (): (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void;158            new (): any;159            readonly prototype: any;160        })[], unknown, unknown, () => void, boolean>;161        readonly action: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "#", boolean>;162        readonly headers: {163            readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => Record<string, any> | Headers) | (() => Record<string, any> | Headers) | ((new (...args: any[]) => Record<string, any> | Headers) | (() => Record<string, any> | Headers))[], unknown, unknown>>;164            readonly required: false;165            readonly validator: ((val: unknown) => boolean) | undefined;166            __epPropKey: true;167        };168        readonly method: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "post", boolean>;169        readonly data: import("element-plus/es/utils").EpPropFinalized<ObjectConstructor, unknown, unknown, () => import("element-plus/es/utils").Mutable<{}>, boolean>;170        readonly multiple: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, false, boolean>;171        readonly name: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "file", boolean>;172        readonly drag: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, false, boolean>;173        readonly withCredentials: BooleanConstructor;174        readonly showFileList: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;175        readonly accept: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;176        readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "select", boolean>;177        readonly fileList: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("./upload").UploadUserFile[]) | (() => import("./upload").UploadUserFile[]) | ((new (...args: any[]) => import("./upload").UploadUserFile[]) | (() => import("./upload").UploadUserFile[]))[], unknown, unknown, () => [], boolean>;178        readonly autoUpload: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;179        readonly listType: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "text" | "picture" | "picture-card", unknown, "text", boolean>;180        readonly httpRequest: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("./upload").UploadRequestHandler) | (() => import("./upload").UploadRequestHandler) | {181            (): import("./upload").UploadRequestHandler;182            new (): any;183            readonly prototype: any;184        } | ((new (...args: any[]) => import("./upload").UploadRequestHandler) | (() => import("./upload").UploadRequestHandler) | {185            (): import("./upload").UploadRequestHandler;186            new (): any;187            readonly prototype: any;188        })[], unknown, unknown, import("./upload").UploadRequestHandler, boolean>;189        readonly disabled: BooleanConstructor;190        readonly limit: NumberConstructor;191    }>> & {192        [x: string & `on${string}`]: ((...args: any[]) => any) | ((...args: unknown[]) => any) | undefined;193    }>>;194    ns: {195        namespace: import("vue").ComputedRef<string>;196        b: (blockSuffix?: string) => string;197        e: (element?: string | undefined) => string;198        m: (modifier?: string | undefined) => string;199        be: (blockSuffix?: string | undefined, element?: string | undefined) => string;200        em: (element?: string | undefined, modifier?: string | undefined) => string;201        bm: (blockSuffix?: string | undefined, modifier?: string | undefined) => string;202        bem: (blockSuffix?: string | undefined, element?: string | undefined, modifier?: string | undefined) => string;203        is: {204            (name: string, state: boolean | undefined): string;205            (name: string): string;206        };207        cssVar: (object: Record<string, string>) => Record<string, string>;208        cssVarName: (name: string) => string;209        cssVarBlock: (object: Record<string, string>) => Record<string, string>;210        cssVarBlockName: (name: string) => string;211    };212    requests: import("vue").ShallowRef<Record<string, XMLHttpRequest | Promise<unknown>>>;213    inputRef: import("vue").ShallowRef<HTMLInputElement | undefined>;214    uploadFiles: (files: File[]) => void;215    upload: (rawFile: UploadRawFile) => Promise<void>;216    doUpload: (rawFile: UploadRawFile) => void;217    handleChange: (e: Event) => void;218    handleClick: () => void;219    handleKeydown: () => void;220    abort: (file?: UploadFile | undefined) => void;221    UploadDragger: import("vue").DefineComponent<{222        readonly disabled: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, false, boolean>;223    }, {224        COMPONENT_NAME: string;225        props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{226            readonly disabled: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, false, boolean>;227        }>> & {228            onFile?: ((file: File[]) => any) | undefined;229        }>>;230        emit: (event: "file", file: File[]) => void;231        uploaderContext: import("../../..").UploadContext;232        ns: {233            namespace: import("vue").ComputedRef<string>;234            b: (blockSuffix?: string) => string;235            e: (element?: string | undefined) => string;236            m: (modifier?: string | undefined) => string;237            be: (blockSuffix?: string | undefined, element?: string | undefined) => string;238            em: (element?: string | undefined, modifier?: string | undefined) => string;239            bm: (blockSuffix?: string | undefined, modifier?: string | undefined) => string;240            bem: (blockSuffix?: string | undefined, element?: string | undefined, modifier?: string | undefined) => string;241            is: {242                (name: string, state: boolean | undefined): string;243                (name: string): string;244            };245            cssVar: (object: Record<string, string>) => Record<string, string>;246            cssVarName: (name: string) => string;247            cssVarBlock: (object: Record<string, string>) => Record<string, string>;248            cssVarBlockName: (name: string) => string;249        };250        dragover: import("vue").Ref<boolean>;251        onDrop: (e: DragEvent) => void;252        onDragover: () => void;253    }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {254        file: (file: File[]) => boolean;255    }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{256        readonly disabled: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, false, boolean>;257    }>> & {258        onFile?: ((file: File[]) => any) | undefined;259    }, {260        readonly disabled: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown>;261    }>;262}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{263    readonly beforeUpload: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>) | (() => (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>) | {264        (): (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>;265        new (): any;266        readonly prototype: any;267    } | ((new (...args: any[]) => (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>) | (() => (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>) | {268        (): (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>;269        new (): any;270        readonly prototype: any;271    })[], unknown, unknown, () => void, boolean>;272    readonly onRemove: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void) | (() => (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void) | {273        (): (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void;274        new (): any;275        readonly prototype: any;276    } | ((new (...args: any[]) => (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void) | (() => (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void) | {277        (): (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void;278        new (): any;279        readonly prototype: any;280    })[], unknown, unknown, () => void, boolean>;281    readonly onStart: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (rawFile: UploadRawFile) => void) | (() => (rawFile: UploadRawFile) => void) | {282        (): (rawFile: UploadRawFile) => void;283        new (): any;284        readonly prototype: any;285    } | ((new (...args: any[]) => (rawFile: UploadRawFile) => void) | (() => (rawFile: UploadRawFile) => void) | {286        (): (rawFile: UploadRawFile) => void;287        new (): any;288        readonly prototype: any;289    })[], unknown, unknown, () => void, boolean>;290    readonly onSuccess: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (response: any, rawFile: UploadRawFile) => unknown) | (() => (response: any, rawFile: UploadRawFile) => unknown) | {291        (): (response: any, rawFile: UploadRawFile) => unknown;292        new (): any;293        readonly prototype: any;294    } | ((new (...args: any[]) => (response: any, rawFile: UploadRawFile) => unknown) | (() => (response: any, rawFile: UploadRawFile) => unknown) | {295        (): (response: any, rawFile: UploadRawFile) => unknown;296        new (): any;297        readonly prototype: any;298    })[], unknown, unknown, () => void, boolean>;299    readonly onProgress: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (evt: import("./upload").UploadProgressEvent, rawFile: UploadRawFile) => void) | (() => (evt: import("./upload").UploadProgressEvent, rawFile: UploadRawFile) => void) | {300        (): (evt: import("./upload").UploadProgressEvent, rawFile: UploadRawFile) => void;301        new (): any;302        readonly prototype: any;303    } | ((new (...args: any[]) => (evt: import("./upload").UploadProgressEvent, rawFile: UploadRawFile) => void) | (() => (evt: import("./upload").UploadProgressEvent, rawFile: UploadRawFile) => void) | {304        (): (evt: import("./upload").UploadProgressEvent, rawFile: UploadRawFile) => void;305        new (): any;306        readonly prototype: any;307    })[], unknown, unknown, () => void, boolean>;308    readonly onError: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (err: import("./ajax").UploadAjaxError, rawFile: UploadRawFile) => void) | (() => (err: import("./ajax").UploadAjaxError, rawFile: UploadRawFile) => void) | {309        (): (err: import("./ajax").UploadAjaxError, rawFile: UploadRawFile) => void;310        new (): any;311        readonly prototype: any;312    } | ((new (...args: any[]) => (err: import("./ajax").UploadAjaxError, rawFile: UploadRawFile) => void) | (() => (err: import("./ajax").UploadAjaxError, rawFile: UploadRawFile) => void) | {313        (): (err: import("./ajax").UploadAjaxError, rawFile: UploadRawFile) => void;314        new (): any;315        readonly prototype: any;316    })[], unknown, unknown, () => void, boolean>;317    readonly onExceed: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void) | (() => (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void) | {318        (): (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void;319        new (): any;320        readonly prototype: any;321    } | ((new (...args: any[]) => (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void) | (() => (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void) | {322        (): (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void;323        new (): any;324        readonly prototype: any;325    })[], unknown, unknown, () => void, boolean>;326    readonly action: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "#", boolean>;327    readonly headers: {328        readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => Record<string, any> | Headers) | (() => Record<string, any> | Headers) | ((new (...args: any[]) => Record<string, any> | Headers) | (() => Record<string, any> | Headers))[], unknown, unknown>>;329        readonly required: false;330        readonly validator: ((val: unknown) => boolean) | undefined;331        __epPropKey: true;332    };333    readonly method: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "post", boolean>;334    readonly data: import("element-plus/es/utils").EpPropFinalized<ObjectConstructor, unknown, unknown, () => import("element-plus/es/utils").Mutable<{}>, boolean>;335    readonly multiple: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, false, boolean>;336    readonly name: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "file", boolean>;337    readonly drag: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, false, boolean>;338    readonly withCredentials: BooleanConstructor;339    readonly showFileList: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;340    readonly accept: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;341    readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "select", boolean>;342    readonly fileList: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("./upload").UploadUserFile[]) | (() => import("./upload").UploadUserFile[]) | ((new (...args: any[]) => import("./upload").UploadUserFile[]) | (() => import("./upload").UploadUserFile[]))[], unknown, unknown, () => [], boolean>;343    readonly autoUpload: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;344    readonly listType: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "text" | "picture" | "picture-card", unknown, "text", boolean>;345    readonly httpRequest: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("./upload").UploadRequestHandler) | (() => import("./upload").UploadRequestHandler) | {346        (): import("./upload").UploadRequestHandler;347        new (): any;348        readonly prototype: any;349    } | ((new (...args: any[]) => import("./upload").UploadRequestHandler) | (() => import("./upload").UploadRequestHandler) | {350        (): import("./upload").UploadRequestHandler;351        new (): any;352        readonly prototype: any;353    })[], unknown, unknown, import("./upload").UploadRequestHandler, boolean>;354    readonly disabled: BooleanConstructor;355    readonly limit: NumberConstructor;356}>>, {357    readonly type: string;358    readonly disabled: boolean;359    readonly name: string;360    readonly drag: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown>;361    readonly multiple: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown>;362    readonly data: Record<string, any>;363    readonly onError: (err: import("./ajax").UploadAjaxError, rawFile: UploadRawFile) => void;364    readonly onProgress: (evt: import("./upload").UploadProgressEvent, rawFile: UploadRawFile) => void;365    readonly action: string;366    readonly method: string;367    readonly showFileList: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown>;368    readonly accept: string;369    readonly fileList: import("./upload").UploadUserFile[];370    readonly autoUpload: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown>;371    readonly listType: import("element-plus/es/utils").EpPropMergeType<StringConstructor, "text" | "picture" | "picture-card", unknown>;372    readonly httpRequest: import("./upload").UploadRequestHandler;373    readonly withCredentials: boolean;374    readonly beforeUpload: (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>;375    readonly onRemove: (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void;376    readonly onSuccess: (response: any, rawFile: UploadRawFile) => unknown;377    readonly onExceed: (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void;378    readonly onStart: (rawFile: UploadRawFile) => void;379}>;...features.py
Source:features.py  
1#!/usr/bin/python2''' Extracts some basic features from PE files. Many of the features3implemented have been used in previously published works. For more information,4check out the following resources:5* Schultz, et al., 2001: http://128.59.14.66/sites/default/files/binaryeval-ieeesp01.pdf6* Kolter and Maloof, 2006: http://www.jmlr.org/papers/volume7/kolter06a/kolter06a.pdf7* Shafiq et al., 2009: https://www.researchgate.net/profile/Fauzan_Mirza/publication/242084613_A_Framework_for_Efficient_Mining_of_Structural_Information_to_Detect_Zero-Day_Malicious_Portable_Executables/links/0c96052e191668c3d5000000.pdf8* Raman, 2012: http://2012.infosecsouthwest.com/files/speaker_materials/ISSW2012_Selecting_Features_to_Classify_Malware.pdf9* Saxe and Berlin, 2015: https://arxiv.org/pdf/1508.03096.pdf10It may be useful to do feature selection to reduce this set of features to a meaningful set11for your modeling problem.12'''13import re14import lief15import hashlib16import numpy as np17from sklearn.feature_extraction import FeatureHasher18class FeatureType(object):19    ''' Base class from which each feature type may inherit '''20    name = ''21    dim = 022    def __repr__(self):23        return '{}({})'.format(self.name, self.dim)24    def raw_features(self, bytez, lief_binary):25        ''' Generate a JSON-able representation of the file '''26        raise (NotImplementedError)27    def process_raw_features(self, raw_obj):28        ''' Generate a feature vector from the raw features '''29        raise (NotImplementedError)30    def feature_vector(self, bytez, lief_binary):31        ''' Directly calculate the feature vector from the sample itself. This should only be implemented differently32        if there are significant speedups to be gained from combining the two functions. '''33        return self.process_raw_features(self.raw_features(bytez, lief_binary))34class ByteHistogram(FeatureType):35    ''' Byte histogram (count + non-normalized) over the entire binary file '''36    name = 'histogram'37    dim = 25638    def __init__(self):39        super(FeatureType, self).__init__()40    def raw_features(self, bytez, lief_binary):41        counts = np.bincount(np.frombuffer(bytez, dtype=np.uint8), minlength=256)42        return counts.tolist()43    def process_raw_features(self, raw_obj):44        counts = np.array(raw_obj, dtype=np.float32)45        sum = counts.sum()46        normalized = counts / sum47        return normalized48class ByteEntropyHistogram(FeatureType):49    ''' 2d byte/entropy histogram based loosely on (Saxe and Berlin, 2015).50    This roughly approximates the joint probability of byte value and local entropy.51    See Section 2.1.1 in https://arxiv.org/pdf/1508.03096.pdf for more info.52    '''53    name = 'byteentropy'54    dim = 25655    def __init__(self, step=1024, window=2048):56        super(FeatureType, self).__init__()57        self.window = window58        self.step = step59    def _entropy_bin_counts(self, block):60        # coarse histogram, 16 bytes per bin61        c = np.bincount(block >> 4, minlength=16)  # 16-bin histogram62        p = c.astype(np.float32) / self.window63        wh = np.where(c)[0]64        H = np.sum(-p[wh] * np.log2(65            p[wh])) * 2  # * x2 b.c. we reduced information by half: 256 bins (8 bits) to 16 bins (4 bits)66        Hbin = int(H * 2)  # up to 16 bins (max entropy is 8 bits)67        if Hbin == 16:  # handle entropy = 8.0 bits68            Hbin = 1569        return Hbin, c70    def raw_features(self, bytez, lief_binary):71        output = np.zeros((16, 16), dtype=np.int)72        a = np.frombuffer(bytez, dtype=np.uint8)73        if a.shape[0] < self.window:74            Hbin, c = self._entropy_bin_counts(a)75            output[Hbin, :] += c76        else:77            # strided trick from here: http://www.rigtorp.se/2011/01/01/rolling-statistics-numpy.html78            shape = a.shape[:-1] + (a.shape[-1] - self.window + 1, self.window)79            strides = a.strides + (a.strides[-1],)80            blocks = np.lib.stride_tricks.as_strided(a, shape=shape, strides=strides)[::self.step, :]81            # from the blocks, compute histogram82            for block in blocks:83                Hbin, c = self._entropy_bin_counts(block)84                output[Hbin, :] += c85        return output.flatten().tolist()86    def process_raw_features(self, raw_obj):87        counts = np.array(raw_obj, dtype=np.float32)88        sum = counts.sum()89        normalized = counts / sum90        return normalized91class SectionInfo(FeatureType):92    ''' Information about section names, sizes and entropy.  Uses hashing trick93    to summarize all this section info into a feature vector.94    '''95    name = 'section'96    dim = 5 + 50 + 50 + 50 + 50 + 5097    def __init__(self):98        super(FeatureType, self).__init__()99    @staticmethod100    def _properties(s):101        return [str(c).split('.')[-1] for c in s.characteristics_lists]102    def raw_features(self, bytez, lief_binary):103        if lief_binary is None:104            return {"entry": "", "sections": []}105        # properties of entry point, or if invalid, the first executable section106        try:107            entry_section = lief_binary.section_from_offset(lief_binary.entrypoint).name108        except lief.not_found:109            # bad entry point, let's find the first executable section110            entry_section = ""111            for s in lief_binary.sections:112                if lief.PE.SECTION_CHARACTERISTICS.MEM_EXECUTE in s.characteristics_lists:113                    entry_section = s.name114                    break115        raw_obj = {"entry": entry_section}116        raw_obj["sections"] = [{117            'name': s.name,118            'size': s.size,119            'entropy': s.entropy,120            'vsize': s.virtual_size,121            'props': self._properties(s)122        } for s in lief_binary.sections]123        return raw_obj124    def process_raw_features(self, raw_obj):125        sections = raw_obj['sections']126        general = [127            len(sections),  # total number of sections128            # number of sections with nonzero size129            sum(1 for s in sections if s['size'] == 0),130            # number of sections with an empty name131            sum(1 for s in sections if s['name'] == ""),132            # number of RX133            sum(1 for s in sections if 'MEM_READ' in s['props'] and 'MEM_EXECUTE' in s['props']),134            # number of W135            sum(1 for s in sections if 'MEM_WRITE' in s['props'])136        ]137        # gross characteristics of each section138        section_sizes = [(s['name'], s['size']) for s in sections]139        section_sizes_hashed = FeatureHasher(50, input_type="pair").transform([section_sizes]).toarray()[0]140        section_entropy = [(s['name'], s['entropy']) for s in sections]141        section_entropy_hashed = FeatureHasher(50, input_type="pair").transform([section_entropy]).toarray()[0]142        section_vsize = [(s['name'], s['vsize']) for s in sections]143        section_vsize_hashed = FeatureHasher(50, input_type="pair").transform([section_vsize]).toarray()[0]144        entry_name_hashed = FeatureHasher(50, input_type="string").transform([raw_obj['entry']]).toarray()[0]145        characteristics = [p for s in sections for p in s['props'] if s['name'] == raw_obj['entry']]146        characteristics_hashed = FeatureHasher(50, input_type="string").transform([characteristics]).toarray()[0]147        return np.hstack([148            general, section_sizes_hashed, section_entropy_hashed, section_vsize_hashed, entry_name_hashed,149            characteristics_hashed150        ]).astype(np.float32)151class ImportsInfo(FeatureType):152    ''' Information about imported libraries and functions from the153    import address table.  Note that the total number of imported154    functions is contained in GeneralFileInfo.155    '''156    name = 'imports'157    dim = 1280158    def __init__(self):159        super(FeatureType, self).__init__()160    def raw_features(self, bytez, lief_binary):161        imports = {}162        if lief_binary is None:163            return imports164        for lib in lief_binary.imports:165            if lib.name not in imports:166                imports[lib.name] = []  # libraries can be duplicated in listing, extend instead of overwrite167            # Clipping assumes there are diminishing returns on the discriminatory power of imported functions168            #  beyond the first 10000 characters, and this will help limit the dataset size169            for entry in lib.entries:170                if entry.is_ordinal:171                    imports[lib.name].append("ordinal" + str(entry.ordinal))172                else:173                    imports[lib.name].append(entry.name[:10000])174        return imports175    def process_raw_features(self, raw_obj):176        # unique libraries177        libraries = list(set([l.lower() for l in raw_obj.keys()]))178        libraries_hashed = FeatureHasher(256, input_type="string").transform([libraries]).toarray()[0]179        # A string like "kernel32.dll:CreateFileMappingA" for each imported function180        imports = [lib.lower() + ':' + e for lib, elist in raw_obj.items() for e in elist]181        imports_hashed = FeatureHasher(1024, input_type="string").transform([imports]).toarray()[0]182        # Two separate elements: libraries (alone) and fully-qualified names of imported functions183        return np.hstack([libraries_hashed, imports_hashed]).astype(np.float32)184class ExportsInfo(FeatureType):185    ''' Information about exported functions. Note that the total number of exported186    functions is contained in GeneralFileInfo.187    '''188    name = 'exports'189    dim = 128190    def __init__(self):191        super(FeatureType, self).__init__()192    def raw_features(self, bytez, lief_binary):193        if lief_binary is None:194            return []195        # Clipping assumes there are diminishing returns on the discriminatory power of exports beyond196        #  the first 10000 characters, and this will help limit the dataset size197        clipped_exports = [export[:10000] for export in lief_binary.exported_functions]198        return clipped_exports199    def process_raw_features(self, raw_obj):200        exports_hashed = FeatureHasher(128, input_type="string").transform([raw_obj]).toarray()[0]201        return exports_hashed.astype(np.float32)202class GeneralFileInfo(FeatureType):203    ''' General information about the file '''204    name = 'general'205    dim = 10206    def __init__(self):207        super(FeatureType, self).__init__()208    def raw_features(self, bytez, lief_binary):209        if lief_binary is None:210            return {211                'size': len(bytez),212                'vsize': 0,213                'has_debug': 0,214                'exports': 0,215                'imports': 0,216                'has_relocations': 0,217                'has_resources': 0,218                'has_signature': 0,219                'has_tls': 0,220                'symbols': 0221            }222        return {223            'size': len(bytez),224            'vsize': lief_binary.virtual_size,225            'has_debug': int(lief_binary.has_debug),226            'exports': len(lief_binary.exported_functions),227            'imports': len(lief_binary.imported_functions),228            'has_relocations': int(lief_binary.has_relocations),229            'has_resources': int(lief_binary.has_resources),230            'has_signature': int(lief_binary.has_signature),231            'has_tls': int(lief_binary.has_tls),232            'symbols': len(lief_binary.symbols),233        }234    def process_raw_features(self, raw_obj):235        return np.asarray([236            raw_obj['size'], raw_obj['vsize'], raw_obj['has_debug'], raw_obj['exports'], raw_obj['imports'],237            raw_obj['has_relocations'], raw_obj['has_resources'], raw_obj['has_signature'], raw_obj['has_tls'],238            raw_obj['symbols']239        ],240                          dtype=np.float32)241class HeaderFileInfo(FeatureType):242    ''' Machine, architecure, OS, linker and other information extracted from header '''243    name = 'header'244    dim = 62245    def __init__(self):246        super(FeatureType, self).__init__()247    def raw_features(self, bytez, lief_binary):248        raw_obj = {}249        raw_obj['coff'] = {'timestamp': 0, 'machine': "", 'characteristics': []}250        raw_obj['optional'] = {251            'subsystem': "",252            'dll_characteristics': [],253            'magic': "",254            'major_image_version': 0,255            'minor_image_version': 0,256            'major_linker_version': 0,257            'minor_linker_version': 0,258            'major_operating_system_version': 0,259            'minor_operating_system_version': 0,260            'major_subsystem_version': 0,261            'minor_subsystem_version': 0,262            'sizeof_code': 0,263            'sizeof_headers': 0,264            'sizeof_heap_commit': 0265        }266        if lief_binary is None:267            return raw_obj268        raw_obj['coff']['timestamp'] = lief_binary.header.time_date_stamps269        raw_obj['coff']['machine'] = str(lief_binary.header.machine).split('.')[-1]270        raw_obj['coff']['characteristics'] = [str(c).split('.')[-1] for c in lief_binary.header.characteristics_list]271        raw_obj['optional']['subsystem'] = str(lief_binary.optional_header.subsystem).split('.')[-1]272        raw_obj['optional']['dll_characteristics'] = [273            str(c).split('.')[-1] for c in lief_binary.optional_header.dll_characteristics_lists274        ]275        raw_obj['optional']['magic'] = str(lief_binary.optional_header.magic).split('.')[-1]276        raw_obj['optional']['major_image_version'] = lief_binary.optional_header.major_image_version277        raw_obj['optional']['minor_image_version'] = lief_binary.optional_header.minor_image_version278        raw_obj['optional']['major_linker_version'] = lief_binary.optional_header.major_linker_version279        raw_obj['optional']['minor_linker_version'] = lief_binary.optional_header.minor_linker_version280        raw_obj['optional'][281            'major_operating_system_version'] = lief_binary.optional_header.major_operating_system_version282        raw_obj['optional'][283            'minor_operating_system_version'] = lief_binary.optional_header.minor_operating_system_version284        raw_obj['optional']['major_subsystem_version'] = lief_binary.optional_header.major_subsystem_version285        raw_obj['optional']['minor_subsystem_version'] = lief_binary.optional_header.minor_subsystem_version286        raw_obj['optional']['sizeof_code'] = lief_binary.optional_header.sizeof_code287        raw_obj['optional']['sizeof_headers'] = lief_binary.optional_header.sizeof_headers288        raw_obj['optional']['sizeof_heap_commit'] = lief_binary.optional_header.sizeof_heap_commit289        return raw_obj290    def process_raw_features(self, raw_obj):291        return np.hstack([292            raw_obj['coff']['timestamp'],293            FeatureHasher(10, input_type="string").transform([[raw_obj['coff']['machine']]]).toarray()[0],294            FeatureHasher(10, input_type="string").transform([raw_obj['coff']['characteristics']]).toarray()[0],295            FeatureHasher(10, input_type="string").transform([[raw_obj['optional']['subsystem']]]).toarray()[0],296            FeatureHasher(10, input_type="string").transform([raw_obj['optional']['dll_characteristics']]).toarray()[0],297            FeatureHasher(10, input_type="string").transform([[raw_obj['optional']['magic']]]).toarray()[0],298            raw_obj['optional']['major_image_version'],299            raw_obj['optional']['minor_image_version'],300            raw_obj['optional']['major_linker_version'],301            raw_obj['optional']['minor_linker_version'],302            raw_obj['optional']['major_operating_system_version'],303            raw_obj['optional']['minor_operating_system_version'],304            raw_obj['optional']['major_subsystem_version'],305            raw_obj['optional']['minor_subsystem_version'],306            raw_obj['optional']['sizeof_code'],307            raw_obj['optional']['sizeof_headers'],308            raw_obj['optional']['sizeof_heap_commit'],309        ]).astype(np.float32)310class StringExtractor(FeatureType):311    ''' Extracts strings from raw byte stream '''312    name = 'strings'313    dim = 1 + 1 + 1 + 96 + 1 + 1 + 1 + 1 + 1314    def __init__(self):315        super(FeatureType, self).__init__()316        # all consecutive runs of 0x20 - 0x7f that are 5+ characters317        self._allstrings = re.compile(b'[\x20-\x7f]{5,}')318        # occurances of the string 'C:\'.  Not actually extracting the path319        self._paths = re.compile(b'c:\\\\', re.IGNORECASE)320        # occurances of http:// or https://.  Not actually extracting the URLs321        self._urls = re.compile(b'https?://', re.IGNORECASE)322        # occurances of the string prefix HKEY_.  No actually extracting registry names323        self._registry = re.compile(b'HKEY_')324        # crude evidence of an MZ header (dropper?) somewhere in the byte stream325        self._mz = re.compile(b'MZ')326    def raw_features(self, bytez, lief_binary):327        allstrings = self._allstrings.findall(bytez)328        if allstrings:329            # statistics about strings:330            string_lengths = [len(s) for s in allstrings]331            avlength = sum(string_lengths) / len(string_lengths)332            # map printable characters 0x20 - 0x7f to an int array consisting of 0-95, inclusive333            as_shifted_string = [b - ord(b'\x20') for b in b''.join(allstrings)]334            c = np.bincount(as_shifted_string, minlength=96)  # histogram count335            # distribution of characters in printable strings336            csum = c.sum()337            p = c.astype(np.float32) / csum338            wh = np.where(c)[0]339            H = np.sum(-p[wh] * np.log2(p[wh]))  # entropy340        else:341            avlength = 0342            c = np.zeros((96,), dtype=np.float32)343            H = 0344            csum = 0345        return {346            'numstrings': len(allstrings),347            'avlength': avlength,348            'printabledist': c.tolist(),  # store non-normalized histogram349            'printables': int(csum),350            'entropy': float(H),351            'paths': len(self._paths.findall(bytez)),352            'urls': len(self._urls.findall(bytez)),353            'registry': len(self._registry.findall(bytez)),354            'MZ': len(self._mz.findall(bytez))355        }356    def process_raw_features(self, raw_obj):357        hist_divisor = float(raw_obj['printables']) if raw_obj['printables'] > 0 else 1.0358        return np.hstack([359            raw_obj['numstrings'], raw_obj['avlength'], raw_obj['printables'],360            np.asarray(raw_obj['printabledist']) / hist_divisor, raw_obj['entropy'], raw_obj['paths'], raw_obj['urls'],361            raw_obj['registry'], raw_obj['MZ']362        ]).astype(np.float32)363class DataDirectories(FeatureType):364    ''' Extracts size and virtual address of the first 15 data directories '''365    name = 'datadirectories'366    dim = 15 * 2367    def __init__(self):368        super(FeatureType, self).__init__()369        self._name_order = [370            "EXPORT_TABLE", "IMPORT_TABLE", "RESOURCE_TABLE", "EXCEPTION_TABLE", "CERTIFICATE_TABLE",371            "BASE_RELOCATION_TABLE", "DEBUG", "ARCHITECTURE", "GLOBAL_PTR", "TLS_TABLE", "LOAD_CONFIG_TABLE",372            "BOUND_IMPORT", "IAT", "DELAY_IMPORT_DESCRIPTOR", "CLR_RUNTIME_HEADER"373        ]374    def raw_features(self, bytez, lief_binary):375        output = []376        if lief_binary is None:377            return output378        for data_directory in lief_binary.data_directories:379            output.append({380                "name": str(data_directory.type).replace("DATA_DIRECTORY.", ""),381                "size": data_directory.size,382                "virtual_address": data_directory.rva383            })384        return output385    def process_raw_features(self, raw_obj):386        features = np.zeros(2 * len(self._name_order), dtype=np.float32)387        for i in range(len(self._name_order)):388            if i < len(raw_obj):389                features[2 * i] = raw_obj[i]["size"]390                features[2 * i + 1] = raw_obj[i]["virtual_address"]391        return features392class PEFeatureExtractor(object):393    ''' Extract useful features from a PE file, and return as a vector of fixed size. '''394    def __init__(self, feature_version=2):395        self.features = [396            ByteHistogram(),397            ByteEntropyHistogram(),398            StringExtractor(),399            GeneralFileInfo(),400            HeaderFileInfo(),401            SectionInfo(),402            ImportsInfo(),403            ExportsInfo()404        ]405        if feature_version == 1:406            if not lief.__version__.startswith("0.8.3"):407                print(f"WARNING: EMBER feature version 1 requires lief version 0.8.3-18d5b75")408                print(f"WARNING:   lief version {lief.__version__} found instead. There may be slight inconsistencies")409                print(f"WARNING:   in the feature calculations.")410        elif feature_version == 2:411            self.features.append(DataDirectories())412            if not lief.__version__.startswith("0.9.0"):413                print(f"WARNING: EMBER feature version 2 requires lief version 0.9.0-")414                print(f"WARNING:   lief version {lief.__version__} found instead. There may be slight inconsistencies")415                print(f"WARNING:   in the feature calculations.")416        else:417            raise Exception(f"EMBER feature version must be 1 or 2. Not {feature_version}")418        self.dim = sum([fe.dim for fe in self.features])419    def raw_features(self, bytez):420        lief_errors = (lief.bad_format, lief.bad_file, lief.pe_error, lief.parser_error, lief.read_out_of_bound,421                       RuntimeError)422        try:423            lief_binary = lief.PE.parse(list(bytez))424        except lief_errors as e:425            print("lief error: ", str(e))426            lief_binary = None427        except Exception:  # everything else (KeyboardInterrupt, SystemExit, ValueError):428            raise429        features = {"sha256": hashlib.sha256(bytez).hexdigest()}430        features.update({fe.name: fe.raw_features(bytez, lief_binary) for fe in self.features})431        return features432    def process_raw_features(self, raw_obj):433        feature_vectors = [fe.process_raw_features(raw_obj[fe.name]) for fe in self.features]434        return np.hstack(feature_vectors).astype(np.float32)435    def feature_vector(self, bytez):...upload-content.d.ts
Source:upload-content.d.ts  
1import type { ExtractPropTypes } from 'vue';2import type { UploadFile, UploadProgressEvent, UploadRawFile } from './upload';3import type UploadContent from './upload-content.vue';4import type { UploadAjaxError } from './ajax';5export declare const uploadContentProps: {6    readonly beforeUpload: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>) | (() => (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>) | {7        (): (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>;8        new (): any;9        readonly prototype: any;10    } | ((new (...args: any[]) => (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>) | (() => (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>) | {11        (): (rawFile: UploadRawFile) => import("element-plus/es/utils").Awaitable<boolean | void | File | Blob | null | undefined>;12        new (): any;13        readonly prototype: any;14    })[], unknown, unknown, () => void, boolean>;15    readonly onRemove: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void) | (() => (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void) | {16        (): (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void;17        new (): any;18        readonly prototype: any;19    } | ((new (...args: any[]) => (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void) | (() => (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void) | {20        (): (file: UploadFile | UploadRawFile, rawFile?: UploadRawFile | undefined) => void;21        new (): any;22        readonly prototype: any;23    })[], unknown, unknown, () => void, boolean>;24    readonly onStart: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (rawFile: UploadRawFile) => void) | (() => (rawFile: UploadRawFile) => void) | {25        (): (rawFile: UploadRawFile) => void;26        new (): any;27        readonly prototype: any;28    } | ((new (...args: any[]) => (rawFile: UploadRawFile) => void) | (() => (rawFile: UploadRawFile) => void) | {29        (): (rawFile: UploadRawFile) => void;30        new (): any;31        readonly prototype: any;32    })[], unknown, unknown, () => void, boolean>;33    readonly onSuccess: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (response: any, rawFile: UploadRawFile) => unknown) | (() => (response: any, rawFile: UploadRawFile) => unknown) | {34        (): (response: any, rawFile: UploadRawFile) => unknown;35        new (): any;36        readonly prototype: any;37    } | ((new (...args: any[]) => (response: any, rawFile: UploadRawFile) => unknown) | (() => (response: any, rawFile: UploadRawFile) => unknown) | {38        (): (response: any, rawFile: UploadRawFile) => unknown;39        new (): any;40        readonly prototype: any;41    })[], unknown, unknown, () => void, boolean>;42    readonly onProgress: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (evt: UploadProgressEvent, rawFile: UploadRawFile) => void) | (() => (evt: UploadProgressEvent, rawFile: UploadRawFile) => void) | {43        (): (evt: UploadProgressEvent, rawFile: UploadRawFile) => void;44        new (): any;45        readonly prototype: any;46    } | ((new (...args: any[]) => (evt: UploadProgressEvent, rawFile: UploadRawFile) => void) | (() => (evt: UploadProgressEvent, rawFile: UploadRawFile) => void) | {47        (): (evt: UploadProgressEvent, rawFile: UploadRawFile) => void;48        new (): any;49        readonly prototype: any;50    })[], unknown, unknown, () => void, boolean>;51    readonly onError: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (err: UploadAjaxError, rawFile: UploadRawFile) => void) | (() => (err: UploadAjaxError, rawFile: UploadRawFile) => void) | {52        (): (err: UploadAjaxError, rawFile: UploadRawFile) => void;53        new (): any;54        readonly prototype: any;55    } | ((new (...args: any[]) => (err: UploadAjaxError, rawFile: UploadRawFile) => void) | (() => (err: UploadAjaxError, rawFile: UploadRawFile) => void) | {56        (): (err: UploadAjaxError, rawFile: UploadRawFile) => void;57        new (): any;58        readonly prototype: any;59    })[], unknown, unknown, () => void, boolean>;60    readonly onExceed: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void) | (() => (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void) | {61        (): (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void;62        new (): any;63        readonly prototype: any;64    } | ((new (...args: any[]) => (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void) | (() => (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void) | {65        (): (files: File[], uploadFiles: import("./upload").UploadUserFile[]) => void;66        new (): any;67        readonly prototype: any;68    })[], unknown, unknown, () => void, boolean>;69    readonly action: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "#", boolean>;70    readonly headers: {71        readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<(new (...args: any[]) => Record<string, any> | Headers) | (() => Record<string, any> | Headers) | ((new (...args: any[]) => Record<string, any> | Headers) | (() => Record<string, any> | Headers))[], unknown, unknown>>;72        readonly required: false;73        readonly validator: ((val: unknown) => boolean) | undefined;74        __epPropKey: true;75    };76    readonly method: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "post", boolean>;77    readonly data: import("element-plus/es/utils").EpPropFinalized<ObjectConstructor, unknown, unknown, () => import("element-plus/es/utils").Mutable<{}>, boolean>;78    readonly multiple: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, false, boolean>;79    readonly name: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "file", boolean>;80    readonly drag: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, false, boolean>;81    readonly withCredentials: BooleanConstructor;82    readonly showFileList: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;83    readonly accept: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "", boolean>;84    readonly type: import("element-plus/es/utils").EpPropFinalized<StringConstructor, unknown, unknown, "select", boolean>;85    readonly fileList: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("./upload").UploadUserFile[]) | (() => import("./upload").UploadUserFile[]) | ((new (...args: any[]) => import("./upload").UploadUserFile[]) | (() => import("./upload").UploadUserFile[]))[], unknown, unknown, () => [], boolean>;86    readonly autoUpload: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;87    readonly listType: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "text" | "picture" | "picture-card", unknown, "text", boolean>;88    readonly httpRequest: import("element-plus/es/utils").EpPropFinalized<(new (...args: any[]) => import("./upload").UploadRequestHandler) | (() => import("./upload").UploadRequestHandler) | {89        (): import("./upload").UploadRequestHandler;90        new (): any;91        readonly prototype: any;92    } | ((new (...args: any[]) => import("./upload").UploadRequestHandler) | (() => import("./upload").UploadRequestHandler) | {93        (): import("./upload").UploadRequestHandler;94        new (): any;95        readonly prototype: any;96    })[], unknown, unknown, import("./upload").UploadRequestHandler, boolean>;97    readonly disabled: BooleanConstructor;98    readonly limit: NumberConstructor;99};100export declare type UploadContentProps = ExtractPropTypes<typeof uploadContentProps>;...rpc_signrawtransaction.py
Source:rpc_signrawtransaction.py  
1#!/usr/bin/env python32# Copyright (c) 2015-2018 The Bitcoin Core developers3# Distributed under the MIT software license, see the accompanying4# file COPYING or http://www.opensource.org/licenses/mit-license.php.5"""Test transaction signing using the signrawtransaction* RPCs."""6from test_framework.test_framework import BitcoinTestFramework7from test_framework.util import assert_equal, assert_raises_rpc_error8from test_framework.digicoinconfig import *9from test_framework.digicoin import convert_btc_address_to_digicoin10class SignRawTransactionsTest(BitcoinTestFramework):11    def set_test_params(self):12        self.setup_clean_chain = True13        self.num_nodes = 114        self.extra_args = [["-deprecatedrpc=signrawtransaction"]]15    def skip_test_if_missing_module(self):16        self.skip_if_no_wallet()17    def successful_signing_test(self):18        """Create and sign a valid raw transaction with one input.19        Expected results:20        1) The transaction has a complete set of signatures21        2) No script verification error occurred"""22        privKeys = ['cUeKHd5orzT3mz8P9pxyREHfsWtVfgsfDjiZZBcjUBAaGk1BTj7N', 'cVKpPfVKSJxKqVpE9awvXNWuLHCa5j5tiE7K6zbUSptFpTEtiFrA']23        inputs = [24            # Valid pay-to-pubkey scripts25            {'txid': '9b907ef1e3c26fc71fe4a4b3580bc75264112f95050014157059c736f0202e71', 'vout': 0,26             'scriptPubKey': '76a91460baa0f494b38ce3c940dea67f3804dc52d1fb9488ac'},27            {'txid': '83a4f6a6b73660e13ee6cb3c6063fa3759c50c9b7521d0536022961898f4fb02', 'vout': 0,28             'scriptPubKey': '76a914669b857c03a5ed269d5d85a1ffac9ed5d663072788ac'},29        ]30        outputs = {convert_btc_address_to_digicoin('mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB'): 0.1}31        rawTx = self.nodes[0].createrawtransaction(inputs, outputs)32        rawTxSigned = self.nodes[0].signrawtransactionwithkey(rawTx, privKeys, inputs)33        # 1) The transaction has a complete set of signatures34        assert rawTxSigned['complete']35        # 2) No script verification error occurred36        assert 'errors' not in rawTxSigned37        # Perform the same test on signrawtransaction38        rawTxSigned2 = self.nodes[0].signrawtransaction(rawTx, inputs, privKeys)39        assert_equal(rawTxSigned, rawTxSigned2)40    def test_with_lock_outputs(self):41        """Test correct error reporting when trying to sign a locked output"""42        self.nodes[0].encryptwallet("password")43        self.restart_node(0)44        rawTx = '020000000156b958f78e3f24e0b2f4e4db1255426b0902027cb37e3ddadb52e37c3557dddb0000000000ffffffff01c0a6b929010000001600149a2ee8c77140a053f36018ac8124a6ececc1668a00000000'45        assert_raises_rpc_error(-13, "Please enter the wallet passphrase with walletpassphrase first", self.nodes[0].signrawtransactionwithwallet, rawTx)46    def script_verification_error_test(self):47        """Create and sign a raw transaction with valid (vin 0), invalid (vin 1) and one missing (vin 2) input script.48        Expected results:49        3) The transaction has no complete set of signatures50        4) Two script verification errors occurred51        5) Script verification errors have certain properties ("txid", "vout", "scriptSig", "sequence", "error")52        6) The verification errors refer to the invalid (vin 1) and missing input (vin 2)"""53        privKeys = ['cUeKHd5orzT3mz8P9pxyREHfsWtVfgsfDjiZZBcjUBAaGk1BTj7N']54        inputs = [55            # Valid pay-to-pubkey script56            {'txid': '9b907ef1e3c26fc71fe4a4b3580bc75264112f95050014157059c736f0202e71', 'vout': 0},57            # Invalid script58            {'txid': '5b8673686910442c644b1f4993d8f7753c7c8fcb5c87ee40d56eaeef25204547', 'vout': 7},59            # Missing scriptPubKey60            {'txid': '9b907ef1e3c26fc71fe4a4b3580bc75264112f95050014157059c736f0202e71', 'vout': 1},61        ]62        scripts = [63            # Valid pay-to-pubkey script64            {'txid': '9b907ef1e3c26fc71fe4a4b3580bc75264112f95050014157059c736f0202e71', 'vout': 0,65             'scriptPubKey': '76a91460baa0f494b38ce3c940dea67f3804dc52d1fb9488ac'},66            # Invalid script67            {'txid': '5b8673686910442c644b1f4993d8f7753c7c8fcb5c87ee40d56eaeef25204547', 'vout': 7,68             'scriptPubKey': 'badbadbadbad'}69        ]70        outputs = {convert_btc_address_to_digicoin('mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB'): 0.1}71        rawTx = self.nodes[0].createrawtransaction(inputs, outputs)72        # Make sure decoderawtransaction is at least marginally sane73        decodedRawTx = self.nodes[0].decoderawtransaction(rawTx)74        for i, inp in enumerate(inputs):75            assert_equal(decodedRawTx["vin"][i]["txid"], inp["txid"])76            assert_equal(decodedRawTx["vin"][i]["vout"], inp["vout"])77        # Make sure decoderawtransaction throws if there is extra data78        assert_raises_rpc_error(-22, "TX decode failed", self.nodes[0].decoderawtransaction, rawTx + "00")79        rawTxSigned = self.nodes[0].signrawtransactionwithkey(rawTx, privKeys, scripts)80        # 3) The transaction has no complete set of signatures81        assert not rawTxSigned['complete']82        # 4) Two script verification errors occurred83        assert 'errors' in rawTxSigned84        assert_equal(len(rawTxSigned['errors']), 2)85        # 5) Script verification errors have certain properties86        assert 'txid' in rawTxSigned['errors'][0]87        assert 'vout' in rawTxSigned['errors'][0]88        assert 'witness' in rawTxSigned['errors'][0]89        assert 'scriptSig' in rawTxSigned['errors'][0]90        assert 'sequence' in rawTxSigned['errors'][0]91        assert 'error' in rawTxSigned['errors'][0]92        # 6) The verification errors refer to the invalid (vin 1) and missing input (vin 2)93        assert_equal(rawTxSigned['errors'][0]['txid'], inputs[1]['txid'])94        assert_equal(rawTxSigned['errors'][0]['vout'], inputs[1]['vout'])95        assert_equal(rawTxSigned['errors'][1]['txid'], inputs[2]['txid'])96        assert_equal(rawTxSigned['errors'][1]['vout'], inputs[2]['vout'])97        assert not rawTxSigned['errors'][0]['witness']98        # Perform same test with signrawtransaction99        rawTxSigned2 = self.nodes[0].signrawtransaction(rawTx, scripts, privKeys)100        assert_equal(rawTxSigned, rawTxSigned2)101        # Now test signing failure for transaction with input witnesses102        p2wpkh_raw_tx = "01000000000102fff7f7881a8099afa6940d42d1e7f6362bec38171ea3edf433541db4e4ad969f00000000494830450221008b9d1dc26ba6a9cb62127b02742fa9d754cd3bebf337f7a55d114c8e5cdd30be022040529b194ba3f9281a99f2b1c0a19c0489bc22ede944ccf4ecbab4cc618ef3ed01eeffffffef51e1b804cc89d182d279655c3aa89e815b1b309fe287d9b2b55d57b90ec68a0100000000ffffffff02202cb206000000001976a9148280b37df378db99f66f85c95a783a76ac7a6d5988ac9093510d000000001976a9143bde42dbee7e4dbe6a21b2d50ce2f0167faa815988ac000247304402203609e17b84f6a7d30c80bfa610b5b4542f32a8a0d5447a12fb1366d7f01cc44a0220573a954c4518331561406f90300e8f3358f51928d43c212a8caed02de67eebee0121025476c2e83188368da1ff3e292e7acafcdb3566bb0ad253f62fc70f07aeee635711000000"103        rawTxSigned = self.nodes[0].signrawtransactionwithwallet(p2wpkh_raw_tx)104        # 7) The transaction has no complete set of signatures105        assert not rawTxSigned['complete']106        # 8) Two script verification errors occurred107        assert 'errors' in rawTxSigned108        assert_equal(len(rawTxSigned['errors']), 2)109        # 9) Script verification errors have certain properties110        assert 'txid' in rawTxSigned['errors'][0]111        assert 'vout' in rawTxSigned['errors'][0]112        assert 'witness' in rawTxSigned['errors'][0]113        assert 'scriptSig' in rawTxSigned['errors'][0]114        assert 'sequence' in rawTxSigned['errors'][0]115        assert 'error' in rawTxSigned['errors'][0]116        # Non-empty witness checked here117        assert_equal(rawTxSigned['errors'][1]['witness'], ["304402203609e17b84f6a7d30c80bfa610b5b4542f32a8a0d5447a12fb1366d7f01cc44a0220573a954c4518331561406f90300e8f3358f51928d43c212a8caed02de67eebee01", "025476c2e83188368da1ff3e292e7acafcdb3566bb0ad253f62fc70f07aeee6357"])118        assert not rawTxSigned['errors'][0]['witness']119        # Perform same test with signrawtransaction120        rawTxSigned2 = self.nodes[0].signrawtransaction(p2wpkh_raw_tx)121        assert_equal(rawTxSigned, rawTxSigned2)122    def run_test(self):123        self.successful_signing_test()124        self.script_verification_error_test()125        self.test_with_lock_outputs()126if __name__ == '__main__':...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
