Skip to content

Conversation

@ukumar-ks
Copy link
Contributor

No description provided.

from .proto import APIRequest_pb2, client_pb2, record_pb2

logger = logging.getLogger(__name__)

Copy link

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:
Copy link

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]:
"""
Copy link

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]:
Copy link

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
"""
Copy link

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)
"""
Copy link

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
Copy link

@sali-ks sali-ks Nov 26, 2025

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
"""
Copy link

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

Copy link

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
"""
Copy link

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
"""
Copy link

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:
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants