-
Notifications
You must be signed in to change notification settings - Fork 1
Implemented Sync security data command #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: sync-security-data
Are you sure you want to change the base?
Conversation
| from .proto import APIRequest_pb2, client_pb2, record_pb2 | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add constants at top like
PASSWORD_PADDING_LENGTH = 25 # Padding length to obfuscate password length in score data
RSA_ENCRYPTION_MAX_SIZE = 244 # Maximum size for RSA encryption (in bytes)
SECURITY_SCORE_UPDATE_CHUNK_SIZE = 1000 # Batch size for security data updates
STRONG_PASSWORD_THRESHOLD = 60 # Minimum score for a password to be considered strong
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def has_passkey(record: vault_record.KeeperRecord) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be private method? __has_passkey()
|
|
||
|
|
||
| def get_password(record: vault_record.KeeperRecord) -> Optional[str]: | ||
| """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__get_password()
| return None | ||
|
|
||
|
|
||
| def get_security_score(record: vault_record.KeeperRecord) -> Optional[int]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__get_security_score()
|
|
||
| Returns: | ||
| Password string or None if no password exists | ||
| """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validate record with None
if not record:
|
|
||
| Returns: | ||
| True if password is considered strong (score >= 60) | ||
| """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Clamp score to valid range and validate as int
if not isinstance(score, int):
return False
score = max(0, min(100, score))
return score >= 60
|
|
||
| # Truncate domain string if needed | ||
| if diff < 0: | ||
| new_length = len(domain) + diff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add validation for new_length
if new_length > 0:
sec_data['domain'] = domain[:new_length]
else:
//If domain would be empty, don't include it
pass
|
|
||
| Returns: | ||
| SecurityData protobuf message or None on error | ||
| """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validate record , vault
if not vault or not record:
return None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also record should have record_uid
if not hasattr(record, 'record_uid') or not record.record_uid:
logger.error('Record UID is missing')
return None
|
|
||
| Returns: | ||
| Encryption type constant from record_pb2 | ||
| """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validate vault
|
|
||
| Returns: | ||
| Number of records successfully updated | ||
| """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validate vault and record
| return sync_security_data_parser | ||
|
|
||
| def execute(self, context: KeeperParams, **kwargs): | ||
| if not context.vault: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add ''' '''' docs or comments of method
| if sap: | ||
| sap.set_reused_passwords(reused_count, 1) | ||
| except Exception: | ||
| pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add exception message like log.error
No description provided.