Skip to content

Commit

Permalink
fix: add hash url option in analysis summary (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidt99 authored Apr 6, 2022
1 parent a47feba commit 2b76a4d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 41 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.6.4 - 1.6.10
-------
- Analysis summary utility improvements

1.6.3
-------
- Fix: analysis summary didn't handle no code reuse report
Expand Down
36 changes: 0 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,39 +137,3 @@ analysis.send(wait=True, wait_timeout=datetime.timedelta(minutes=1))
## Code examples
You can find more code examples under [analyze-python-sdk/examples/](https://github.com/intezer/analyze-python-sdk/tree/master/examples) directory

## Changelog

### 1.6.4
- Feat: Added functionality

### 1.6.3
- Fix: analysis summary didn't handle no code reuse report

### 1.6.2
- Fix: analysis summary didn't look for genes in root analysis

### 1.6.1
- Fix: Handle no iocs correctly

### 1.6
- Feat: Add analysis summary utility function
- Fix: Handle no ttps correctly

### 1.5
- Feat: Add family search
- Feat: Support for zip password
- Feat: Add iocs and dynamic ttps to analysis
- Feat: Add capabilities to sub analysis

### 1.4.5
- Feat: Add a timeout option when waiting for operation completion

### 1.4.4
- Feat: Add Verify SSL toggle to Intezer api to ignore ssl verification

### 1.4.2
- Fix: Sub analyses should get the API Class like Analysis
- Doc: Add description to pypi

### Breaking changes in 1.0
- In `Analysis`: Change `dynamic_unpacking` and `static_unpacking` to `disable_dynamic_unpacking` and `disable_static_unpacking`
2 changes: 1 addition & 1 deletion intezer_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.6.9'
__version__ = '1.6.10'
3 changes: 2 additions & 1 deletion intezer_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class CodeItemType(Enum):
MEMORY_MODULE = 'memory_module'


BASE_URL = 'https://analyze.intezer.com/api/'
ANALYZE_URL = 'https://analyze.intezer.com'
BASE_URL = f'{ANALYZE_URL}/api/'
API_VERSION = 'v2-0'
USER_AGENT = 'intezer-python-sdk-{}'.format(__version__)
CHECK_STATUS_INTERVAL = 1
13 changes: 10 additions & 3 deletions intezer_sdk/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Tuple

from intezer_sdk.analysis import Analysis
from intezer_sdk.consts import ANALYZE_URL

emojis_by_key = {
'trusted': '✅',
Expand All @@ -14,14 +15,15 @@
'result_url': '👉'
}


def _get_title(short: bool) -> str:
if short:
return 'Intezer Analysis: \n'
return (f'Intezer Analysis\n'
f'=========================\n\n')


def get_analysis_summary(analysis: Analysis, no_emojis: bool = False, short: bool = False) -> str:
def get_analysis_summary(analysis: Analysis, no_emojis: bool = False, short: bool = False, use_hash_link=False) -> str:
result = analysis.result()

metadata = analysis.get_root_analysis().metadata
Expand Down Expand Up @@ -53,8 +55,13 @@ def get_analysis_summary(analysis: Analysis, no_emojis: bool = False, short: boo
if gene_count and not short:
note = f'{note} ({gene_count} shared code genes)'

if use_hash_link:
analysis_url = f"{ANALYZE_URL}/files/{result['sha256']}?private=true"
else:
analysis_url = result['analysis_url']

if short:
return f'{note} > {result["analysis_url"]}'
return f'{note} > {analysis_url}'

note = f'{note}\n\nSize: {human_readable_size(metadata["size_in_bytes"])}\n'

Expand Down Expand Up @@ -91,7 +98,7 @@ def get_analysis_summary(analysis: Analysis, no_emojis: bool = False, short: boo
note = f'{note}Similar previous uploads: {related_samples_unique_count} files \n'

note = (f'{note}\nFull report:\n'
f'{"" if no_emojis else get_emoji("result_url")} {result["analysis_url"]}')
f'{"" if no_emojis else get_emoji("result_url")} {analysis_url}')

return note

Expand Down

0 comments on commit 2b76a4d

Please sign in to comment.