-
Notifications
You must be signed in to change notification settings - Fork 51
Coe fix #432
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
Coe fix #432
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #!/usr/bin/env python3 | ||
| """Behavioral device simulation for PCILeech firmware generation. | ||
|
|
||
| This module provides behavioral simulation capabilities that make generated | ||
| firmware behave like real devices (e.g., Ethernet showing as connected, | ||
| NVMe showing as ready). | ||
| """ | ||
|
|
||
| from .base import ( | ||
| BehaviorType, | ||
| BehavioralRegister, | ||
| BehavioralCounter, | ||
| BehavioralSpec | ||
| ) | ||
| from .analyzer import ( | ||
| BehavioralAnalyzerFactory, | ||
| generate_behavioral_spec | ||
| ) | ||
|
|
||
| __all__ = [ | ||
| 'BehaviorType', | ||
| 'BehavioralRegister', | ||
| 'BehavioralCounter', | ||
| 'BehavioralSpec', | ||
| 'BehavioralAnalyzerFactory', | ||
| 'generate_behavioral_spec', | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #!/usr/bin/env python3 | ||
| """Behavioral analyzer factory and dispatcher.""" | ||
|
|
||
| import logging | ||
| from typing import Any, Optional | ||
|
|
||
| from string_utils import log_info_safe, log_warning_safe, safe_format | ||
| from .base import BehavioralSpec | ||
| from .network_behavioral import NetworkBehavioralAnalyzer | ||
| from .storage_behavioral import StorageBehavioralAnalyzer | ||
| from .media_behavioral import MediaBehavioralAnalyzer | ||
|
|
||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class BehavioralAnalyzerFactory: | ||
| """Factory for creating device-specific behavioral analyzers.""" | ||
|
|
||
| @staticmethod | ||
| def create_analyzer(device_config: Any) -> Optional[Any]: | ||
| """Create appropriate behavioral analyzer based on device class.""" | ||
| class_code = getattr(device_config, 'class_code', 0) | ||
| device_class = (class_code >> 16) & 0xFF | ||
|
|
||
| log_info_safe(logger, safe_format("Creating behavioral analyzer for class=0x{cls:02X}", | ||
| cls=device_class)) | ||
|
|
||
| if device_class == 0x02: # Network controller | ||
| return NetworkBehavioralAnalyzer(device_config) | ||
| elif device_class == 0x01: # Storage controller | ||
| return StorageBehavioralAnalyzer(device_config) | ||
| elif device_class == 0x04: # Multimedia controller | ||
| return MediaBehavioralAnalyzer(device_config) | ||
| else: | ||
| log_warning_safe(logger, safe_format("No behavioral analyzer for class=0x{cls:02X}", | ||
| cls=device_class)) | ||
| return None | ||
|
|
||
| @staticmethod | ||
| def generate_behavioral_spec(device_config: Any) -> Optional[BehavioralSpec]: | ||
| """Generate behavioral specification for device.""" | ||
| if not getattr(device_config, 'enable_behavioral_simulation', False): | ||
| log_info_safe(logger, "Behavioral simulation disabled") | ||
| return None | ||
|
|
||
| analyzer = BehavioralAnalyzerFactory.create_analyzer(device_config) | ||
| if not analyzer: | ||
| return None | ||
|
|
||
| return analyzer.generate_spec() | ||
|
|
||
|
|
||
| def generate_behavioral_spec(device_config: Any) -> Optional[BehavioralSpec]: | ||
| """Convenience function to generate behavioral spec.""" | ||
| return BehavioralAnalyzerFactory.generate_behavioral_spec(device_config) | ||
| Original file line number | Diff line number | Diff line change | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,131 @@ | |||||||||||||||||||||||||||||
| #!/usr/bin/env python3 | |||||||||||||||||||||||||||||
| """Base behavioral register infrastructure for device simulation.""" | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| import logging | |||||||||||||||||||||||||||||
| from typing import Dict, Any, List, Optional | |||||||||||||||||||||||||||||
Check noticeCode scanning / CodeQL Unused import Note
Import of 'List' is not used.
Copilot AutofixAI 5 days ago To fix the problem, remove the unused import of
Suggested changeset
1
src/behavioral/base.py
Copilot is powered by AI and may make mistakes. Always verify output.
Positive FeedbackNegative Feedback
Refresh and try again.
|
|||||||||||||||||||||||||||||
| from dataclasses import dataclass | |||||||||||||||||||||||||||||
| from enum import Enum | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| from string_utils import log_error_safe, log_debug_safe, safe_format | |||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
| from string_utils import log_error_safe, log_debug_safe, safe_format | |
| from src.string_utils import log_error_safe, log_debug_safe, safe_format |
Copilot uses AI. Check for mistakes.
Copilot
AI
Oct 19, 2025
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.
The log_error_safe function call is missing the logger parameter as the first argument. This should be 'log_error_safe(logger, safe_format(...))' to match the function signature used elsewhere in the codebase.
| log_error_safe(safe_format("Build aborted: {msg} | ctx={ctx}", | |
| log_error_safe(logger, safe_format("Build aborted: {msg} | ctx={ctx}", |
Copilot uses AI. Check for mistakes.
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.
The import path 'string_utils' is incorrect. Based on the codebase structure, this should be 'from src.string_utils import ...' to maintain consistency.
Copilot uses AI. Check for mistakes.