Skip to content

Commit

Permalink
Merge commit from fork
Browse files Browse the repository at this point in the history
* security: set 600 permissions on auth token cache file

/~https://github.com/spotipy-dev/spotipy/security/advisories/GHSA-pwhh-q4h6-w599

* Update spotipy/cache_handler.py

Co-authored-by: Niko <github@dieserniko.link>

* add newline back in

---------

Co-authored-by: Niko <github@dieserniko.link>
  • Loading branch information
alichtman and dieser-niko authored Feb 26, 2025
1 parent 668158f commit 1ca453f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Add your changes below.

- Fixed scripts in examples directory that didn't run correctly
- Updated documentation for `Client.current_user_top_artists` to indicate maximum number of artists limit
- Set auth cache file permissions to `600`: /~https://github.com/spotipy-dev/spotipy/security/advisories/GHSA-pwhh-q4h6-w599

### Changed

Expand Down
4 changes: 4 additions & 0 deletions spotipy/cache_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,12 @@ def save_token_to_cache(self, token_info):
try:
with open(self.cache_path, "w", encoding='utf-8') as f:
f.write(json.dumps(token_info, cls=self.encoder_cls))
# /~https://github.com/spotipy-dev/spotipy/security/advisories/GHSA-pwhh-q4h6-w599
os.chmod(self.cache_path, 0o600)
except OSError:
logger.warning(f"Couldn't write token to cache at: {self.cache_path}")
except FileNotFoundError:
logger.warning(f"Couldn't set permissions to cache file at: {self.cache_path}")


class MemoryCacheHandler(CacheHandler):
Expand Down

0 comments on commit 1ca453f

Please sign in to comment.