openapi: 3.0.0
servers:
  - url: http://restful4up.local
  - url: /v1
info:
  description: RESTful API 4 Unipacker
  title: RESTful4Up
  version: 1.0.0
  x-apisguru-categories:
    - developer_tools
  x-origin:
    - format: openapi
      url: https://raw.githubusercontent.com/rpgeeganage/restful4up/master/app/spec/api.yml
      version: "3.0"
  x-providerName: restful4up.local
  x-logo:
    url: https://api.apis.guru/v2/cache/logo/https_apis.guru_assets_images_no-logo.svg
paths:
  /apply-yara-rules:
    post:
      description: apply given YARA rules to the given executable. (upto 10 rules)
      operationId: applyYaraRules
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                file:
                  description: file
                  format: binary
                  type: string
                is_unpacking_required:
                  enum:
                    - "true"
                    - "false"
                  type: string
                rules:
                  items:
                    description: Rule as BASE-64 encoded string
                    type: string
                  maxItems: 10
                  minItems: 1
                  type: array
              required:
                - file
                - rules
        required: true
      responses:
        "200":
          content:
            "*/*":
              schema:
                properties:
                  result:
                    $ref: "#/components/schemas/apply_yara_rule"
          description: Yara rules
        "400":
          content:
            "*/*":
              schema:
                $ref: "#/components/schemas/error"
          description: request error
        "500":
          content:
            "*/*":
              schema:
                $ref: "#/components/schemas/error"
          description: server error
  /clean:
    head:
      description: clean up the uploaded files
      operationId: clean
      responses:
        "204":
          description: Ok
        "500":
          content:
            "*/*":
              schema:
                $ref: "#/components/schemas/error"
          description: server error
  /emulation-output:
    post:
      description: try to get the emulation output after unpacking the file
      operationId: emulationOutput
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                file:
                  description: file
                  format: binary
                  type: string
              required:
                - file
        required: true
      responses:
        "200":
          content:
            "*/*":
              schema:
                properties:
                  output:
                    items:
                      type: string
                    type: array
                required:
                  - output
          description: emulation output after unpacking the file
        "400":
          content:
            "*/*":
              schema:
                $ref: "#/components/schemas/error"
          description: request error
        "500":
          content:
            "*/*":
              schema:
                $ref: "#/components/schemas/error"
          description: server error
  /generate-partial-yara-rules:
    post:
      description: generate partial YARA rules for give executable. (Rule without the condition section)
      operationId: generatePartialYaraRule
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                file:
                  description: file
                  format: binary
                  type: string
                is_unpacking_required:
                  enum:
                    - "true"
                    - "false"
                  type: string
                minimum_string_length:
                  type: string
                strings_to_ignore:
                  items:
                    type: string
                  maxItems: 1000
                  minItems: 0
                  type: array
              required:
                - file
        required: true
      responses:
        "200":
          content:
            "*/*":
              schema:
                properties:
                  rule:
                    $ref: "#/components/schemas/yara"
          description: Yara rules
        "400":
          content:
            "*/*":
              schema:
                $ref: "#/components/schemas/error"
          description: request error
        "500":
          content:
            "*/*":
              schema:
                $ref: "#/components/schemas/error"
          description: server error
  /unpack:
    post:
      description: try to unpack the given file
      operationId: unpack
      requestBody:
        content:
          multipart/form-data:
            schema:
              properties:
                file:
                  description: file
                  format: binary
                  type: string
              required:
                - file
        required: true
      responses:
        "200":
          content:
            "*/*":
              schema:
                format: binary
                type: string
          description: Ok
        "400":
          content:
            "*/*":
              schema:
                $ref: "#/components/schemas/error"
          description: request error
        "500":
          content:
            "*/*":
              schema:
                $ref: "#/components/schemas/error"
          description: server error
components:
  schemas:
    apply_yara_rule:
      properties:
        error_message:
          description: error message, if YARA failed
          type: string
        is_success:
          description: is operation success
          type: boolean
        matched_yara_rules:
          description: matched YARA rules
          items:
            items:
              description: Yara rule meta data section
              properties:
                rule:
                  description: matched rule
                  type: string
                string_information:
                  description: string which matched during the scanning
                  items:
                    type: string
                  type: array
              required:
                - rule
                - string_information
              type: object
            type: array
          type: array
        yara_command:
          description: Yara command executed
          type: string
      required:
        - yara_command
        - is_success
    error:
      properties:
        message:
          type: string
        status:
          type: integer
      required:
        - status
        - message
      type: object
    yara:
      properties:
        meta:
          description: Yara rule meta data section
          properties:
            date:
              description: Date of the YARA rule created
              type: string
            md5sum:
              description: MD5 check sum
              type: string
            sha256sum:
              description: SHA 256 check sum
              type: string
            sha512sum:
              description: SHA 512 check sum
              type: string
          required:
            - date
            - md5sum
            - sha256sum
            - sha512sum
          type: object
        name:
          description: Yara rule name
          type: string
        strings:
          description: Yara rule string section
          items:
            items:
              type: string
            maxItems: 2
            minItems: 2
            type: array
          type: array
      required:
        - name
        - meta
        - strings
