Skip to content

Commit 19984f2

Browse files
authored
Merge branch 'master' into user/sanjuyadav/vso_task_lib_runtime
2 parents db60db5 + 80dd37c commit 19984f2

File tree

8 files changed

+33
-2
lines changed

8 files changed

+33
-2
lines changed

docs/threat-model/AgentsTasks-ThreatModel.tm7

Lines changed: 4 additions & 0 deletions
Large diffs are not rendered by default.
Loading
Loading
Loading
Loading

docs/threat-model/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Threat Model
2+
3+
A threat model provides a visual representation of how components in the stack interact. When the model is accurate, security and compliance teams can evaluate it effectively, identifying potential vulnerabilities and areas for optimization.
4+
5+
Keeping the threat model up to date helps protect **both** customer data and Microsoft assets.
6+
7+
- 📥 [Download the Threat Modeling Tool](https://aka.ms/threatmodelingtool)
8+
- 📚 [Learn more about threat modeling](https://osgwiki.com/wiki/Task_-_Services_Security:_Complete_And_Upload_A_Threat_Model)
9+
10+
> **Note:** Diagrams of various flows are exported and checked in as PNGs for easy reference.
11+
> When updating the threat model, make sure to check in the latest PNG to:
12+
> `azure-pipelines-agent/docs/threat-model/Export`

src/Agent.Plugins/GitSourceProvider.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,11 +937,18 @@ public async Task GetSourceAsync(
937937
executionContext.Debug($"sourceVersion : {sourceVersion}");
938938
executionContext.Debug($"fetchTags : {fetchTags}");
939939

940+
// Determine if we should use fetch by commit based on shallow vs full clone scenarios
941+
bool shouldFetchByCommit = fetchByCommit && !string.IsNullOrEmpty(sourceVersion) &&
942+
(fetchDepth > 0 || AgentKnobs.FetchByCommitForFullClone.GetValue(executionContext).AsBoolean());
943+
944+
executionContext.Debug($"shouldFetchByCommit : {shouldFetchByCommit}");
945+
940946
if (IsPullRequest(sourceBranch))
941947
{
942948
// Build a 'fetch-by-commit' refspec iff the server allows us to do so in the shallow fetch scenario
949+
// or if it's a full clone and the FetchByCommitForFullClone knob is enabled
943950
// Otherwise, fall back to fetch all branches and pull request ref
944-
if (fetchDepth > 0 && fetchByCommit && !string.IsNullOrEmpty(sourceVersion))
951+
if (shouldFetchByCommit)
945952
{
946953
refFetchedByCommit = $"{_remoteRefsPrefix}{sourceVersion}";
947954
additionalFetchSpecs.Add($"+{sourceVersion}:{refFetchedByCommit}");
@@ -955,8 +962,9 @@ public async Task GetSourceAsync(
955962
else
956963
{
957964
// Build a refspec iff the server allows us to fetch a specific commit in the shallow fetch scenario
965+
// or if it's a full clone and the FetchByCommitForFullClone knob is enabled
958966
// Otherwise, use the default fetch behavior (i.e. with no refspecs)
959-
if (fetchDepth > 0 && fetchByCommit && !string.IsNullOrEmpty(sourceVersion))
967+
if (shouldFetchByCommit)
960968
{
961969
refFetchedByCommit = $"{_remoteRefsPrefix}{sourceVersion}";
962970
additionalFetchSpecs.Add($"+{sourceVersion}:{refFetchedByCommit}");

src/Agent.Sdk/Knob/AgentKnobs.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@ public class AgentKnobs
200200
new EnvironmentKnobSource("AGENT_USE_NODE20_IN_UNSUPPORTED_SYSTEM"),
201201
new BuiltInDefaultKnobSource("false"));
202202

203+
public static readonly Knob FetchByCommitForFullClone = new Knob(
204+
nameof(FetchByCommitForFullClone),
205+
"If true, allow fetch by commit when doing a full clone (depth=0).",
206+
new RuntimeKnobSource("VSTS.FetchByCommitForFullClone"),
207+
new EnvironmentKnobSource("VSTS_FETCHBYCOMMITFORFULLCLONE"),
208+
new BuiltInDefaultKnobSource("false"));
209+
203210
// Agent logging
204211
public static readonly Knob AgentPerflog = new Knob(
205212
nameof(AgentPerflog),

0 commit comments

Comments
 (0)