Merge branch 'main' into dependabot/nuget/src/Runner.Sdk/main/System.Text.Encoding.CodePages-10.0.6
This commit is contained in:
@@ -32,7 +32,7 @@ namespace GitHub.Actions.WorkflowParser.Conversion
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var effectiveMax = explicitMax ?? CreatePermissionsFromPolicy(context, permissionsPolicy, includeIdToken: isTrusted, includeModels: context.GetFeatures().AllowModelsPermission);
|
var effectiveMax = explicitMax ?? CreatePermissionsFromPolicy(context, permissionsPolicy, includeIdToken: isTrusted, includeModels: context.GetFeatures().AllowModelsPermission, includeVulnerabilityAlerts: context.GetFeatures().AllowVulnerabilityAlertsPermission);
|
||||||
|
|
||||||
if (requested.ViolatesMaxPermissions(effectiveMax, out var permissionLevelViolations))
|
if (requested.ViolatesMaxPermissions(effectiveMax, out var permissionLevelViolations))
|
||||||
{
|
{
|
||||||
@@ -59,18 +59,19 @@ namespace GitHub.Actions.WorkflowParser.Conversion
|
|||||||
TemplateContext context,
|
TemplateContext context,
|
||||||
string permissionsPolicy,
|
string permissionsPolicy,
|
||||||
bool includeIdToken,
|
bool includeIdToken,
|
||||||
bool includeModels)
|
bool includeModels,
|
||||||
|
bool includeVulnerabilityAlerts)
|
||||||
{
|
{
|
||||||
switch (permissionsPolicy)
|
switch (permissionsPolicy)
|
||||||
{
|
{
|
||||||
case WorkflowConstants.PermissionsPolicy.LimitedRead:
|
case WorkflowConstants.PermissionsPolicy.LimitedRead:
|
||||||
return new Permissions(PermissionLevel.NoAccess, includeIdToken: false, includeAttestations: false, includeModels: false)
|
return new Permissions(PermissionLevel.NoAccess, includeIdToken: false, includeAttestations: false, includeModels: false, includeVulnerabilityAlerts: false)
|
||||||
{
|
{
|
||||||
Contents = PermissionLevel.Read,
|
Contents = PermissionLevel.Read,
|
||||||
Packages = PermissionLevel.Read,
|
Packages = PermissionLevel.Read,
|
||||||
};
|
};
|
||||||
case WorkflowConstants.PermissionsPolicy.Write:
|
case WorkflowConstants.PermissionsPolicy.Write:
|
||||||
return new Permissions(PermissionLevel.Write, includeIdToken: includeIdToken, includeAttestations: true, includeModels: includeModels);
|
return new Permissions(PermissionLevel.Write, includeIdToken: includeIdToken, includeAttestations: true, includeModels: includeModels, includeVulnerabilityAlerts: includeVulnerabilityAlerts);
|
||||||
default:
|
default:
|
||||||
throw new ArgumentException($"Unexpected permission policy: '{permissionsPolicy}'");
|
throw new ArgumentException($"Unexpected permission policy: '{permissionsPolicy}'");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1877,7 +1877,7 @@ namespace GitHub.Actions.WorkflowParser.Conversion
|
|||||||
permissionsStr.AssertUnexpectedValue(permissionsStr.Value);
|
permissionsStr.AssertUnexpectedValue(permissionsStr.Value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return new Permissions(permissionLevel, includeIdToken: true, includeAttestations: true, includeModels: context.GetFeatures().AllowModelsPermission);
|
return new Permissions(permissionLevel, includeIdToken: true, includeAttestations: true, includeModels: context.GetFeatures().AllowModelsPermission, includeVulnerabilityAlerts: context.GetFeatures().AllowVulnerabilityAlertsPermission);
|
||||||
}
|
}
|
||||||
|
|
||||||
var mapping = token.AssertMapping("permissions");
|
var mapping = token.AssertMapping("permissions");
|
||||||
@@ -1957,6 +1957,23 @@ namespace GitHub.Actions.WorkflowParser.Conversion
|
|||||||
context.Error(key, $"The permission 'models' is not allowed");
|
context.Error(key, $"The permission 'models' is not allowed");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "vulnerability-alerts":
|
||||||
|
if (context.GetFeatures().AllowVulnerabilityAlertsPermission)
|
||||||
|
{
|
||||||
|
if (permissionLevel == PermissionLevel.Write)
|
||||||
|
{
|
||||||
|
permissions.VulnerabilityAlerts = PermissionLevel.Read;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
permissions.VulnerabilityAlerts = permissionLevel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context.Error(key, $"The permission 'vulnerability-alerts' is not allowed");
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ namespace GitHub.Actions.WorkflowParser
|
|||||||
SecurityEvents = copy.SecurityEvents;
|
SecurityEvents = copy.SecurityEvents;
|
||||||
IdToken = copy.IdToken;
|
IdToken = copy.IdToken;
|
||||||
Models = copy.Models;
|
Models = copy.Models;
|
||||||
|
VulnerabilityAlerts = copy.VulnerabilityAlerts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Permissions(
|
public Permissions(
|
||||||
@@ -61,6 +62,19 @@ namespace GitHub.Actions.WorkflowParser
|
|||||||
: PermissionLevel.NoAccess;
|
: PermissionLevel.NoAccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Permissions(
|
||||||
|
PermissionLevel permissionLevel,
|
||||||
|
bool includeIdToken,
|
||||||
|
bool includeAttestations,
|
||||||
|
bool includeModels,
|
||||||
|
bool includeVulnerabilityAlerts)
|
||||||
|
: this(permissionLevel, includeIdToken, includeAttestations, includeModels)
|
||||||
|
{
|
||||||
|
VulnerabilityAlerts = includeVulnerabilityAlerts
|
||||||
|
? (permissionLevel == PermissionLevel.Write ? PermissionLevel.Read : permissionLevel)
|
||||||
|
: PermissionLevel.NoAccess;
|
||||||
|
}
|
||||||
|
|
||||||
private static KeyValuePair<string, (PermissionLevel, PermissionLevel)>[] ComparisonKeyMapping(Permissions left, Permissions right)
|
private static KeyValuePair<string, (PermissionLevel, PermissionLevel)>[] ComparisonKeyMapping(Permissions left, Permissions right)
|
||||||
{
|
{
|
||||||
return new[]
|
return new[]
|
||||||
@@ -81,6 +95,7 @@ namespace GitHub.Actions.WorkflowParser
|
|||||||
new KeyValuePair<string, (PermissionLevel, PermissionLevel)>("security-events", (left.SecurityEvents, right.SecurityEvents)),
|
new KeyValuePair<string, (PermissionLevel, PermissionLevel)>("security-events", (left.SecurityEvents, right.SecurityEvents)),
|
||||||
new KeyValuePair<string, (PermissionLevel, PermissionLevel)>("id-token", (left.IdToken, right.IdToken)),
|
new KeyValuePair<string, (PermissionLevel, PermissionLevel)>("id-token", (left.IdToken, right.IdToken)),
|
||||||
new KeyValuePair<string, (PermissionLevel, PermissionLevel)>("models", (left.Models, right.Models)),
|
new KeyValuePair<string, (PermissionLevel, PermissionLevel)>("models", (left.Models, right.Models)),
|
||||||
|
new KeyValuePair<string, (PermissionLevel, PermissionLevel)>("vulnerability-alerts", (left.VulnerabilityAlerts, right.VulnerabilityAlerts)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,6 +169,13 @@ namespace GitHub.Actions.WorkflowParser
|
|||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DataMember(Name = "vulnerability-alerts", EmitDefaultValue = false)]
|
||||||
|
public PermissionLevel VulnerabilityAlerts
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
[DataMember(Name = "packages", EmitDefaultValue = false)]
|
[DataMember(Name = "packages", EmitDefaultValue = false)]
|
||||||
public PermissionLevel Packages
|
public PermissionLevel Packages
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,6 +41,13 @@ namespace GitHub.Actions.WorkflowParser
|
|||||||
[DataMember(EmitDefaultValue = false)]
|
[DataMember(EmitDefaultValue = false)]
|
||||||
public bool AllowModelsPermission { get; set; }
|
public bool AllowModelsPermission { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether users may use the "vulnerability-alerts" permission.
|
||||||
|
/// Used during parsing only.
|
||||||
|
/// </summary>
|
||||||
|
[DataMember(EmitDefaultValue = false)]
|
||||||
|
public bool AllowVulnerabilityAlertsPermission { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether the expression function fromJson performs strict JSON parsing.
|
/// Gets or sets a value indicating whether the expression function fromJson performs strict JSON parsing.
|
||||||
/// Used during evaluation only.
|
/// Used during evaluation only.
|
||||||
@@ -67,6 +74,7 @@ namespace GitHub.Actions.WorkflowParser
|
|||||||
Snapshot = false, // Default to false since this feature is still in an experimental phase
|
Snapshot = false, // Default to false since this feature is still in an experimental phase
|
||||||
StrictJsonParsing = false, // Default to false since this is temporary for telemetry purposes only
|
StrictJsonParsing = false, // Default to false since this is temporary for telemetry purposes only
|
||||||
AllowModelsPermission = false, // Default to false since we want this to be disabled for all non-production environments
|
AllowModelsPermission = false, // Default to false since we want this to be disabled for all non-production environments
|
||||||
|
AllowVulnerabilityAlertsPermission = false, // Default to false since we want this to be disabled for all non-production environments
|
||||||
AllowServiceContainerCommand = false, // Default to false since this feature is gated by actions_service_container_command
|
AllowServiceContainerCommand = false, // Default to false since this feature is gated by actions_service_container_command
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -496,8 +496,8 @@
|
|||||||
"check-suite-activity": {
|
"check-suite-activity": {
|
||||||
"description": "The types of check suite activity that trigger the workflow. Supported activity types: `completed`.",
|
"description": "The types of check suite activity that trigger the workflow. Supported activity types: `completed`.",
|
||||||
"one-of": [
|
"one-of": [
|
||||||
"check-suite-activity-type",
|
"check-suite-activity-type",
|
||||||
"check-suite-activity-types"
|
"check-suite-activity-types"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"check-suite-activity-types": {
|
"check-suite-activity-types": {
|
||||||
@@ -1865,11 +1865,15 @@
|
|||||||
},
|
},
|
||||||
"security-events": {
|
"security-events": {
|
||||||
"type": "permission-level-any",
|
"type": "permission-level-any",
|
||||||
"description": "Code scanning and Dependabot alerts."
|
"description": "Code scanning alerts."
|
||||||
},
|
},
|
||||||
"statuses": {
|
"statuses": {
|
||||||
"type": "permission-level-any",
|
"type": "permission-level-any",
|
||||||
"description": "Commit statuses."
|
"description": "Commit statuses."
|
||||||
|
},
|
||||||
|
"vulnerability-alerts": {
|
||||||
|
"type": "permission-level-read-or-no-access",
|
||||||
|
"description": "Dependabot alerts."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user