Skip to content

Expand Azure Pipelines model foundation - #393

Open
Chanel (chanel-y) wants to merge 2 commits into
mainfrom
iac-p0/ado-model-foundation
Open

Expand Azure Pipelines model foundation#393
Chanel (chanel-y) wants to merge 2 commits into
mainfrom
iac-p0/ado-model-foundation

Conversation

@chanel-y

Copy link
Copy Markdown

Add structural model coverage for Azure Pipelines documents and templates, including parameters, stages, jobs, checkout/template steps, script variants, and repository/pipeline resources.

Add structural model coverage for Azure Pipelines documents and templates, including parameters, stages, jobs, checkout/template steps, script variants, and repository/pipeline resources.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8eab11c3-3153-4036-9847-28a2f615835f
@chanel-y
Chanel (chanel-y) force-pushed the iac-p0/ado-model-foundation branch from c687a1d to db8aea2 Compare August 26, 2026 17:03
GitHub Actions workflows share `jobs:`/`steps:` keys with Azure DevOps
pipelines, so the shape-based Document match misclassified them. Exclude
documents that live under .github/workflows/ or declare a top-level `on:`
trigger, and regenerate the AST test expectations. Adds a github-workflow.yml
regression input.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly stylistic comments. I think we should revisit all the predicate names / QLDoc for the "getters" implemented in this PR so that it conforms to the standard naming / phrasing conventions (i.e., the comment I put here: https://github.com/microsoft/codeql/pull/393/changes#r3926233771), but otherwise this all looks good!

Comment on lines +44 to +47
/**
* Gets a top-level trigger-like entry.
*/
YamlValue getTrigger(string name) { result = this.lookup(name) }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* Gets a top-level trigger-like entry.
*/
YamlValue getTrigger(string name) { result = this.lookup(name) }
/**
* Gets the top-level trigger-like entry named `name`, if any.
*/
YamlValue getTrigger(string name) { result = this.lookup(name) }

Comment on lines +54 to +57
/**
* Gets the pipeline parameters.
*/
Parameter getParameters() { result = this.lookup("parameters").getAChild() }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some QLDoc terminology that I'd really like us to switch to. A predicate can essentially fall into 4 categories:

  1. It always has 1 result
  2. It has at most 1 result (i.e., 0 or 1 result)
  3. It has 0 or more results
  4. It has 1 or more results

Each of these comes with recommended phrasing for the name of the predicate, and phrasing for the QLDoc:

  1. If the predicate always has 1 result it should be named getX (for some appropriate X), and its QLDoc should be written as Gets the X. For example:
    /**
     * Gets the parameter associated with this `Document`.
     */
    Parameter getParameter() { result = .... }
  2. If the predicate has at most 1 result (i.e., 0 or 1) it should be named getX, and its QLDoc should be written as Gets the X, if any.. For example:
    /**
     * Gets the parameter associated with this `Document`, if any.
     */
    Parameter getParameter() { result = .... }
  3. If the predicate has 0 or more results it should be named getAX (or getAnX), and its QLDoc should be written as Gets an X, if any.. For example:
    /**
     * Gets a parameter associated with this `Document`, if any.
     */
    Parameter getAParameter() { result = .... }
  4. If the predicate has 1 or more results it should be named getAX (or getAnX), and its QLDoc should be written as Gets an X.. For example:
    /**
     * Gets a parameter associated with this `Document`.
     */
    Parameter getAParameter() { result = .... }

The name getParameters doesn't fall into any of these 4 categories. So I don't know how many results I can expect from this query!

class Stage extends YamlNode, YamlMapping {
Stage() { exists(Document document | document.lookup("stages").getAChildNode() = this) }

override string toString() { result = "Stage '" + this.getName() + "'" }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember this comment I made a while back in the context of TSQL support:

Image

Based on that comment from old me, I would prefer we made this toString output just this.getName(). But if you think otherwise I'm happy to be corrected!

exists(Stage stage | stage.lookup("jobs").getAChildNode() = this)
}

override string toString() { result = "Job '" + this.getName() + "'" }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. I think this should just be result = this.getName().

Comment on lines +283 to +285
exists(Document document | document.lookup("steps").getAChildNode() = this | result = document)
or
exists(Document document | this.getFile() = document.getFile() | result = document)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a convoluted way to say this:

Suggested change
exists(Document document | document.lookup("steps").getAChildNode() = this | result = document)
or
exists(Document document | this.getFile() = document.getFile() | result = document)
result.lookup("steps").getAChildNode() = this
or
this.getFile() = result.getFile()

Comment on lines +395 to +399
exists(Document document |
document.lookup("resources").(YamlMapping).lookup("repositories").getAChildNode() = this
|
result = document
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exists(Document document |
document.lookup("resources").(YamlMapping).lookup("repositories").getAChildNode() = this
|
result = document
)
result.lookup("resources").(YamlMapping).lookup("repositories").getAChildNode() = this

Comment on lines +434 to +438
exists(Document document |
document.lookup("resources").(YamlMapping).lookup("pipelines").getAChildNode() = this
|
result = document
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exists(Document document |
document.lookup("resources").(YamlMapping).lookup("pipelines").getAChildNode() = this
|
result = document
)
result.lookup("resources").(YamlMapping).lookup("pipelines").getAChildNode() = this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants