代码拉取完成,页面将自动刷新
def calculate_aivss_score():
"""Calculates the AIVSS score interactively based on user input and the updated scoring rubric."""
# Define the AIVSS parameter values with descriptions for user selection
av_values = {
"1": {"value": 0.85, "description": "Network"},
"2": {"value": 0.62, "description": "Adjacent Network"},
"3": {"value": 0.55, "description": "Local"},
"4": {"value": 0.20, "description": "Physical"},
}
ac_values = {
"1": {"value": 0.77, "description": "Low"},
"2": {"value": 0.44, "description": "High"},
}
pr_values = {
"1": {"value": 0.85, "description": "None"},
"2": {"value": 0.62, "description": "Low"},
"3": {"value": 0.27, "description": "High"},
}
ui_values = {
"1": {"value": 0.85, "description": "None"},
"2": {"value": 0.62, "description": "Required"},
}
s_values = {
"1": {"value": 1.00, "description": "Unchanged"},
"2": {"value": 1.50, "description": "Changed"},
}
mr_values = {
"1": {"value": 1.00, "description": "Very High"},
"2": {"value": 0.80, "description": "High"},
"3": {"value": 0.60, "description": "Medium"},
"4": {"value": 0.40, "description": "Low"},
"5": {"value": 0.20, "description": "Very Low"},
}
ds_values = {
"1": {"value": 1.00, "description": "Very High"},
"2": {"value": 0.80, "description": "High"},
"3": {"value": 0.60, "description": "Medium"},
"4": {"value": 0.40, "description": "Low"},
"5": {"value": 0.20, "description": "Very Low"},
}
ei_values = {
"1": {"value": 1.00, "description": "Very High"},
"2": {"value": 0.80, "description": "High"},
"3": {"value": 0.60, "description": "Medium"},
"4": {"value": 0.40, "description": "Low"},
"5": {"value": 0.20, "description": "Very Low"},
}
dc_values = {
"1": {"value": 1.00, "description": "Very High"},
"2": {"value": 0.80, "description": "High"},
"3": {"value": 0.60, "description": "Medium"},
"4": {"value": 0.40, "description": "Low"},
"5": {"value": 0.20, "description": "Very Low"},
}
ad_values = {
"1": {"value": 1.00, "description": "Very High"},
"2": {"value": 0.80, "description": "High"},
"3": {"value": 0.60, "description": "Medium"},
"4": {"value": 0.40, "description": "Low"},
"5": {"value": 0.20, "description": "Very Low"},
}
c_values = {
"1": {"value": 0.00, "description": "None"},
"2": {"value": 0.22, "description": "Low"},
"3": {"value": 0.56, "description": "Medium"},
"4": {"value": 0.85, "description": "High"},
"5": {"value": 1.00, "description": "Critical"},
}
i_values = {
"1": {"value": 0.00, "description": "None"},
"2": {"value": 0.22, "description": "Low"},
"3": {"value": 0.56, "description": "Medium"},
"4": {"value": 0.85, "description": "High"},
"5": {"value": 1.00, "description": "Critical"},
}
a_values = {
"1": {"value": 0.00, "description": "None"},
"2": {"value": 0.22, "description": "Low"},
"3": {"value": 0.56, "description": "Medium"},
"4": {"value": 0.85, "description": "High"},
"5": {"value": 1.00, "description": "Critical"},
}
si_values = {
"1": {"value": 0.00, "description": "None"},
"2": {"value": 0.22, "description": "Low"},
"3": {"value": 0.56, "description": "Medium"},
"4": {"value": 0.85, "description": "High"},
"5": {"value": 1.00, "description": "Critical"},
}
# Get user input for each parameter
def get_user_input(parameter_name, values):
print(f"\nSelect {parameter_name}:")
for key, value in values.items():
print(f"{key}. {value['description']}")
choice = input("Enter your choice: ")
while choice not in values:
print("Invalid choice. Please try again.")
choice = input("Enter your choice: ")
return values[choice]["value"]
attack_vector = get_user_input("Attack Vector (AV)", av_values)
attack_complexity = get_user_input("Attack Complexity (AC)", ac_values)
privileges_required = get_user_input("Privileges Required (PR)", pr_values)
user_interaction = get_user_input("User Interaction (UI)", ui_values)
scope = get_user_input("Scope (S)", s_values)
model_robustness = get_user_input("Model Robustness (MR)", mr_values)
data_sensitivity = get_user_input("Data Sensitivity (DS)", ds_values)
ethical_impact = get_user_input("Ethical Impact (EI)", ei_values)
decision_criticality = get_user_input(
"Decision Criticality (DC)", dc_values
)
adaptability = get_user_input("Adaptability (AD)", ad_values)
confidentiality_impact = get_user_input(
"Confidentiality Impact (C)", c_values
)
integrity_impact = get_user_input("Integrity Impact (I)", i_values)
availability_impact = get_user_input("Availability Impact (A)", a_values)
safety_impact = get_user_input("Safety Impact (SI)", si_values)
# Calculate the base metrics score
base_metrics = (
attack_vector
* attack_complexity
* privileges_required
* user_interaction
* scope
)
base_metrics = min(10, base_metrics) # Cap the base metrics score at 10
# Calculate the AI-specific metrics score
ai_specific_metrics = (
model_robustness
* data_sensitivity
* ethical_impact
* decision_criticality
* adaptability
)
# Calculate the impact metrics score
impact_metrics = (
confidentiality_impact
+ integrity_impact
+ availability_impact
+ safety_impact
) / 4
# Calculate the final AIVSS score using updated weights
w1 = 0.25
w2 = 0.45
w3 = 0.30
aivss_score = (
w1 * base_metrics + w2 * ai_specific_metrics + w3 * impact_metrics
)
return aivss_score
# Example usage
aivss_score = calculate_aivss_score()
print(f"\nThe AIVSS score is: {aivss_score:.2f}")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。