From 682b47fbd3e24a8a53c3b484ba896a5dbc85cda2 Mon Sep 17 00:00:00 2001 From: r4sas Date: Fri, 20 Sep 2019 10:50:06 +0000 Subject: [PATCH] 0.3.0 New: * Added validation of PrivateBin instance URL - #18 (it must contain trailing slash because POST is used) * URL shortener support with various supported services - #19 * Shortener configuration, certificate validation and insecure warning settings can be configured in config file or via env Changed: * Restructured some parts of code by splitting big code chunks in funtions (encrypt/decrypt) * Rework error messaging repeatable code (moved in utils) * Reduce code duplication (requests session configuring) Signed-off-by: r4sas --- .gitattributes | 1 + pbincli/__init__.py | 2 +- pbincli/api.py | 13 ++++++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index 5966153..c252504 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ .gitattributes export-ignore .gitignore export-ignore +README.md export-ignore diff --git a/pbincli/__init__.py b/pbincli/__init__.py index cdc0096..831f5c6 100644 --- a/pbincli/__init__.py +++ b/pbincli/__init__.py @@ -2,6 +2,6 @@ # -*- coding: utf-8 -*- __author__ = "R4SAS " -__version__ = "0.2.2b1" +__version__ = "0.3.0" __copyright__ = "Copyright (c) R4SAS" __license__ = "MIT" diff --git a/pbincli/api.py b/pbincli/api.py index 3b4bf41..fe76d77 100644 --- a/pbincli/api.py +++ b/pbincli/api.py @@ -98,8 +98,19 @@ class Shortener: def _yourls_init(self, settings): if not settings['short_url']: PBinCLIError("YOURLS: An API URL is required") - self.apiurl = settings['short_url'] + # setting API URL + apiurl = settings['short_url'] + if apiurl.endswith('/yourls-api.php'): + self.apiurl = apiurl + elif apiurl.endswith('/'): + self.apiurl = apiurl + 'yourls-api.php' + else: + PBinCLIError("YOURLS: Incorrect URL is provided.\n" + + "It must contain full address to 'yourls-api.php' script (like https://example.com/yourls-api.php)\n" + + "or just contain instance URL with '/' at the end (like https://example.com/)") + + # validating for required credentials if settings['short_user'] and settings['short_pass'] and settings['short_token'] is None: self.auth_args = {'username': settings['short_user'], 'password': settings['short_pass']} elif settings['short_user'] is None and settings['short_pass'] is None and settings['short_token']: