Skip to content

Commit

Permalink
Use tabbed code blocks when there are multiple examples
Browse files Browse the repository at this point in the history
Some rule docs include mulitple examples. In those cases, it's
better to use a tabbed block so the page looks cleaner.

Signed-off-by: Eric Brown <[email protected]>
  • Loading branch information
ericwb committed Jul 19, 2024
1 parent 634d045 commit 77c9dab
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ markdown_extensions:
- pymdownx.inlinehilite
- pymdownx.snippets
- pymdownx.superfences
- pymdownx.tabbed:
alternate_style: true
40 changes: 24 additions & 16 deletions precli/rules/python/stdlib/crypt_weak_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,46 @@
## Examples
```python linenums="1" hl_lines="4"
import crypt
=== "crypt.crypt"
```python linenums="1" hl_lines="4"
import crypt
crypt.crypt("password", salt=crypt.METHOD_MD5)
```
```python linenums="1" hl_lines="4"
import crypt
crypt.crypt("password", salt=crypt.METHOD_MD5)
```
=== "crypt.mksalt"
crypt.mksalt(crypt.METHOD_CRYPT)
```
```python linenums="1" hl_lines="4"
import crypt
crypt.mksalt(crypt.METHOD_CRYPT)
```
## Remediation
The recommendation is to swap the insecure hashing method to one of the more
secure alternatives, `SHA256` or `SHA512`.
```python linenums="1" hl_lines="4"
import crypt
=== "crypt.crypt"
```python linenums="1" hl_lines="4"
import crypt
crypt.crypt("password", salt=crypt.METHOD_SHA256)
```
crypt.crypt("password", salt=crypt.METHOD_SHA256)
```
=== "crypt.mksalt"
```python linenums="1" hl_lines="4"
import crypt
```python linenums="1" hl_lines="4"
import crypt
crypt.mksalt(crypt.METHOD_SHA512)
```
crypt.mksalt(crypt.METHOD_SHA512)
```
## Alternatives to Crypt
Expand Down

0 comments on commit 77c9dab

Please sign in to comment.