<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Sandblast - Threat Prevention API - Upload a file via an Webinterface in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Sandblast-Threat-Prevention-API-Upload-a-file-via-an/m-p/64037#M3986</link>
    <description>&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;This is a very interesting question. For me it is also not clear what to do with the state partially_found.&lt;/P&gt;&lt;P&gt;Can you provide an answer here please?&lt;/P&gt;</description>
    <pubDate>Tue, 01 Oct 2019 07:59:27 GMT</pubDate>
    <dc:creator>hueppisam</dc:creator>
    <dc:date>2019-10-01T07:59:27Z</dc:date>
    <item>
      <title>Sandblast - Threat Prevention API - Upload a file via an Webinterface</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Sandblast-Threat-Prevention-API-Upload-a-file-via-an/m-p/2909#M243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm currently playing around with the Threat Prevention API and my goal is to create a web interface to upload a suspicious file to the (on premise) Sandblast appliance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is my current partly working Python(Flask) code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@app.route('/upload', methods=['GET', 'POST'])&lt;/P&gt;&lt;P&gt;def upload():&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if request.method == 'POST':&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; file = request.files['file']&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resp=do_upload(file)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return render_template('index.html', msg='success', json=resp)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return render_template('upload.html')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def do_upload(file):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; filestream = file.stream&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hostname='&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://LOCALSANDBLAST:18194/tecloud/api/v1/file/upload" rel="nofollow"&gt;https://LOCALSANDBLAST:18194/tecloud/api/v1/file/upload&lt;/A&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; payload={"request":{"file_name":file.filename}}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; files = {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'request': (None, json.dumps(payload), 'application/json'),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'file': (file.filename, filestream)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; response=requests.post(hostname, files=files)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return response.text&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print response.text&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However the response I get from the Threat Prevention API contains the code '1006' which according to the documentation is 'PARTIALLY_FOUND: Part of the request found. If the missing data is required, upload the file.'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The complete response is attached to this post.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What am I doing wrong? Am I not uploading the whole file?&lt;/P&gt;&lt;P&gt;Can you maybe provide a working example for uploading and successfully querying a threat emulation via HASH afterwards?&lt;/P&gt;&lt;P&gt;Would be very happy to hear your ideas / approaches.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Johanna&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Jan 2017 14:05:27 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Sandblast-Threat-Prevention-API-Upload-a-file-via-an/m-p/2909#M243</guid>
      <dc:creator>Johanna_Müller</dc:creator>
      <dc:date>2017-01-16T14:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Sandblast - Threat Prevention API - Upload a file via an Webinterface</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Sandblast-Threat-Prevention-API-Upload-a-file-via-an/m-p/64037#M3986</link>
      <description>&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;This is a very interesting question. For me it is also not clear what to do with the state partially_found.&lt;/P&gt;&lt;P&gt;Can you provide an answer here please?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 07:59:27 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Sandblast-Threat-Prevention-API-Upload-a-file-via-an/m-p/64037#M3986</guid>
      <dc:creator>hueppisam</dc:creator>
      <dc:date>2019-10-01T07:59:27Z</dc:date>
    </item>
  </channel>
</rss>

