-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -268,6 +268,7 @@ def get_tok(self, tok): | |
|
||
if rm_tok: | ||
self.rm_token(tok) | ||
return {} | ||
|
||
return tdata | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- coding: utf-8 -*- | ||
import os | ||
import time | ||
import salt.auth | ||
import salt.config | ||
from tests.support.runtests import RUNTIME_VARS | ||
from tests.support.unit import TestCase | ||
|
||
|
||
|
||
class AuthTest(TestCase): | ||
|
||
def test_cve_2021_3244(self): | ||
opts = { | ||
"extension_modules": "", | ||
"optimization_order": [0, 1, 2], | ||
"token_expire": 1, | ||
"keep_acl_in_token": False, | ||
"eauth_tokens": "localfs", | ||
"token_dir": RUNTIME_VARS.TMP, | ||
"token_expire_user_override": True, | ||
"external_auth": { | ||
"auto": { | ||
"foo": [] | ||
} | ||
} | ||
} | ||
auth = salt.auth.LoadAuth(opts) | ||
load = { | ||
"eauth": "auto", | ||
"username": "foo", | ||
"password": "foo", | ||
"token_expire": -1} | ||
t_data = auth.mk_token(load) | ||
assert t_data['expire'] < time.time() | ||
token_file = os.path.join(RUNTIME_VARS.TMP, t_data['token']) | ||
assert os.path.exists(token_file) | ||
t_data = auth.get_tok(t_data['token']) | ||
assert not os.path.exists(token_file) | ||
assert t_data == {} |