Skip to content

Commit

Permalink
Merge pull request #48 from PaperMtn/release/4.0.2
Browse files Browse the repository at this point in the history
Release/4.0.2
  • Loading branch information
PaperMtn committed Jun 14, 2023
2 parents 2ff530f + 4dc2300 commit a9c6b3a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [4.0.2] - 2023-06-14
### Added
- Added notification for an invalid cookie being passed (Fixes #47)
### Fixed
- JSON output for User and Workspace information was malformed, this has now been fixed

## [4.0.1] - 2023-05-05
### Changed
- User output in stdout logging now includes display name and email. The accounts for cases where usernames are nonsensical.
Expand Down
2 changes: 1 addition & 1 deletion src/slack_watchman/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
]

__title__ = 'Slack Watchman'
__version__ = '4.0.1'
__version__ = '4.0.2'
__summary__ = 'Monitoring and enumerating Slack for exposed secrets'
__author__ = 'PaperMtn'
__email__ = '[email protected]'
Expand Down
11 changes: 11 additions & 0 deletions src/slack_watchman/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ def __init__(self, config_entry):
super().__init__(self.message)


class InvalidCookieError(Exception):
""" Exception raised when the provided cookie is not valid, or it does not
nave access to the workspace given.
"""

def __init__(self, domain):
self.message = "The cookie may not be valid or, if it is valid," \
f" the user it belongs to cant authenticate to the Slack workspace {domain}"
super().__init__(self.message)


class SlackScopeError(Exception):
""" Exception raised when the authed user doesn't have the required API scopes
"""
Expand Down
7 changes: 6 additions & 1 deletion src/slack_watchman/slack_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ def _get_session_token(self) -> str:
r = requests.get(self.url, cookies=self.cookie_dict).text
regex = '(xox[a-zA-Z]-[a-zA-Z0-9-]+)'

return re.search(regex, r)[0]
try:
return re.search(regex, r)[0]
except TypeError:
raise exceptions.InvalidCookieError(self.url)
except:
raise

def _make_request(self, url, params=None, data=None, method='GET', verify_ssl=True):
try:
Expand Down
6 changes: 3 additions & 3 deletions src/slack_watchman/sw_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def print_header(self) -> None:
""" + Style.RESET_ALL
)
print(' Slack Watchman ')
print(Style.DIM + ' Detect exposed secrets in Slack ' + Style.RESET_ALL)
print(Style.DIM + ' Slack enumeration and exposed secrets detection tool ' + Style.RESET_ALL)
print(' ')
print(Style.BRIGHT + ' by PaperMtn - GNU General Public License')
print(' '.ljust(79) + Fore.GREEN)
Expand All @@ -219,9 +219,9 @@ def __init__(self, name: str = 'Slack Watchman', **kwargs):
self.success_format = logging.Formatter(
'{"timestamp": "%(asctime)s", "level": "SUCCESS", "message": "%(message)s"}')
self.user_format = logging.Formatter(
'{"timestamp": "%(asctime)s", "level": "USER", "message": "%(message)s"}')
'{"timestamp": "%(asctime)s", "level": "USER", "message": %(message)s}')
self.workspace_format = logging.Formatter(
'{"timestamp": "%(asctime)s", "level": "WORKSPACE", "message": "%(message)s"}')
'{"timestamp": "%(asctime)s", "level": "WORKSPACE", "message": %(message)s}')
self.logger = logging.getLogger(self.name)
self.handler = logging.StreamHandler(sys.stdout)
self.logger.addHandler(self.handler)
Expand Down

0 comments on commit a9c6b3a

Please sign in to comment.