graph LR
Email_Validation_Utilities["Email Validation & Utilities"]
ContentBase["ContentBase"]
PlainTextContent["PlainTextContent"]
AmpHtmlContent["AmpHtmlContent"]
HtmlContent["HtmlContent"]
ApiKeyValidator["ApiKeyValidator"]
ApiKeyException["ApiKeyException"]
PlainTextContent -- "inherits from" --> ContentBase
AmpHtmlContent -- "inherits from" --> ContentBase
HtmlContent -- "inherits from" --> ContentBase
ContentBase -- "uses" --> ApiKeyValidator
PlainTextContent -- "uses" --> ApiKeyValidator
AmpHtmlContent -- "uses" --> ApiKeyValidator
HtmlContent -- "uses" --> ApiKeyValidator
ApiKeyValidator -- "raises" --> ApiKeyException
This system provides robust email content validation, primarily focusing on preventing the accidental inclusion of SendGrid API keys within email messages. It defines a base structure for various email content types (plain text, HTML, AMP HTML) and integrates a dedicated API key validation mechanism. The system ensures that all content, regardless of its type, is scanned for sensitive information before being processed, and raises a specific exception if an API key is detected, thereby enhancing security.
Provides utility functions for validating email message components, particularly to prevent sensitive information like API keys from being included in email content, and defines related exceptions.
Related Classes/Methods:
sendgrid.helpers.mail.validators.ValidateApiKey(4:69)sendgrid.helpers.mail.exceptions.ApiKeyIncludedException(11:65)sendgrid.helpers.mail.mime_type.MimeType(1:6)
Provides the foundational structure and properties for various email content types, including MIME type and content value. It also integrates with the API key validation mechanism.
Related Classes/Methods:
sendgrid.helpers.mail.content.Content(5:81)sendgrid.helpers.mail.content.Content:__init__(11:27)sendgrid.helpers.mail.content.Content:content(51:56)
Represents plain text email content, inheriting from the ContentBase. It ensures that plain text content is validated for API keys before being set.
Related Classes/Methods:
sendgrid.helpers.mail.plain_text_content.PlainTextContent(5:60)sendgrid.helpers.mail.plain_text_content.PlainTextContent:__init__(9:19)sendgrid.helpers.mail.plain_text_content.PlainTextContent:content(30:35)
Represents AMP HTML email content, inheriting from the ContentBase. It validates AMP HTML content for API keys.
Related Classes/Methods:
sendgrid.helpers.mail.amp_html_content.AmpHtmlContent(5:59)sendgrid.helpers.mail.amp_html_content.AmpHtmlContent:__init__(8:18)sendgrid.helpers.mail.amp_html_content.AmpHtmlContent:content(29:34)
Represents standard HTML email content, inheriting from the ContentBase. It validates HTML content for API keys.
Related Classes/Methods:
sendgrid.helpers.mail.html_content.HtmlContent(5:59)sendgrid.helpers.mail.html_content.HtmlContent:__init__(8:18)sendgrid.helpers.mail.html_content.HtmlContent:content(29:34)
Responsible for scanning email content (both dictionary and string formats) to detect and prevent the accidental inclusion of SendGrid API keys, raising an exception if found.
Related Classes/Methods:
sendgrid.helpers.mail.validators.ValidateApiKey(4:69)sendgrid.helpers.mail.validators.ValidateApiKey:validate_message_dict(30:55)sendgrid.helpers.mail.validators.ValidateApiKey:validate_message_text(57:69)
Defines the specific exception raised when a SendGrid API key is detected within the email content during validation.
Related Classes/Methods: