Skip to content

feature(x2a): AAP Project now linked as artifact on UI #2439

Open
elai-shalev wants to merge 2 commits intoredhat-developer:mainfrom
elai-shalev:artifacts-url-pubish
Open

feature(x2a): AAP Project now linked as artifact on UI #2439
elai-shalev wants to merge 2 commits intoredhat-developer:mainfrom
elai-shalev:artifacts-url-pubish

Conversation

@elai-shalev
Copy link
Contributor

Follow up of #2420
This PR will add the link to the Ansible Project in AAP as an artifact returned from the reporter
image

@elai-shalev elai-shalev changed the title Artifacts url pubish feature(x2a): AAP Project now linked as artifact on UI Mar 4, 2026
@rhdh-gh-app
Copy link

rhdh-gh-app bot commented Mar 4, 2026

Missing Changesets

The following package(s) are changed by this PR but do not have a changeset:

  • @red-hat-developer-hub/backstage-plugin-x2a-backend
  • @red-hat-developer-hub/backstage-plugin-x2a

See CONTRIBUTING.md for more information about how to add changesets.

Changed Packages

Package Name Package Path Changeset Bump Current Version
@red-hat-developer-hub/backstage-plugin-x2a-backend workspaces/x2a/plugins/x2a-backend none v1.0.1
@red-hat-developer-hub/backstage-plugin-x2a workspaces/x2a/plugins/x2a none v1.0.1

@rhdh-qodo-merge
Copy link

Review Summary by Qodo

Update AAP artifact URL publishing and labeling

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Update artifact labels from "Ansible Project" to "AAP Project" across all translations
• Modify AAP artifact to use direct project URL instead of local path
• Parse AAP project ID from publish-aap output to construct clickable URL
• Simplify ansible_project artifact rendering in UI components
Diagram
flowchart LR
  A["publish-aap script"] -->|Parse project ID| B["AAP URL construction"]
  B -->|artifact.value| C["ArtifactsCard component"]
  C -->|Direct link| D["AAP Controller URL"]
  E["Translation files"] -->|AAP Project label| C
Loading

Grey Divider

File Changes

1. workspaces/x2a/plugins/x2a/src/translations/de.ts 📝 Documentation +2/-2

Update German translations for AAP artifact

• Changed 'Ansible-Projekt' to 'AAP-Projekt' in artifact type labels
• Updated both artifact.types and modulePage.artifacts translation keys

workspaces/x2a/plugins/x2a/src/translations/de.ts


2. workspaces/x2a/plugins/x2a/src/translations/es.ts 📝 Documentation +6/-6

Update Spanish translations for AAP artifact

• Changed 'Proyecto Ansible' to 'Proyecto AAP' in artifact type labels
• Updated both artifact.types and modulePage.artifacts translation keys
• Fixed encoding issues in 'lastUpdate', 'lastPhase', and 'success' fields

workspaces/x2a/plugins/x2a/src/translations/es.ts


3. workspaces/x2a/plugins/x2a/src/translations/fr.ts 📝 Documentation +2/-2

Update French translations for AAP artifact

• Changed 'Projet Ansible' to 'Projet AAP' in artifact type labels
• Updated both artifact.types and modulePage.artifacts translation keys

workspaces/x2a/plugins/x2a/src/translations/fr.ts


View more (5)
4. workspaces/x2a/plugins/x2a/src/translations/it.ts 📝 Documentation +2/-2

Update Italian translations for AAP artifact

• Changed 'Progetto Ansible' to 'Progetto AAP' in artifact type labels
• Updated both artifact.types and modulePage.artifacts translation keys

workspaces/x2a/plugins/x2a/src/translations/it.ts


5. workspaces/x2a/plugins/x2a/src/translations/ref.ts 📝 Documentation +2/-2

Update reference translations for AAP artifact

• Changed 'Ansible Project' to 'AAP Project' in artifact type labels
• Updated both artifact.types and modulePage.artifacts translation keys

workspaces/x2a/plugins/x2a/src/translations/ref.ts


6. workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh ✨ Enhancement +11/-4

Parse AAP project ID and construct artifact URL

• Capture publish-aap command output to parse AAP project ID
• Extract project ID using grep pattern matching from output
• Construct full AAP Controller URL with project ID for artifact value
• Fallback to base projects URL if ID parsing fails

workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh


7. workspaces/x2a/plugins/x2a/src/components/ModulePage/ArtifactsCard.tsx ✨ Enhancement +11/-5

Simplify ansible_project artifact rendering

• Replace ArtifactLink component with direct Link for ansible_project artifacts
• Use artifact.value directly as URL instead of building from repo parameters
• Add null check and fallback to 'none' phase label when artifact missing

workspaces/x2a/plugins/x2a/src/components/ModulePage/ArtifactsCard.tsx


8. workspaces/x2a/plugins/x2a/src/components/ModuleTable/Artifacts.tsx ✨ Enhancement +5/-1

Handle ansible_project URL separately in artifact link

• Add conditional logic to use artifact.value directly for ansible_project type
• Build URL only for non-ansible_project artifacts using existing helper
• Preserve backward compatibility for other artifact types

workspaces/x2a/plugins/x2a/src/components/ModuleTable/Artifacts.tsx


Grey Divider

Qodo Logo

@rhdh-qodo-merge
Copy link

rhdh-qodo-merge bot commented Mar 4, 2026

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Unvalidated AAP artifact URL 🐞 Bug ⛨ Security
Description
The UI now renders ansible_project using artifact.value directly as a link, while the backend
accepts aapCredentials.url as an arbitrary string and passes it into the job env. A malformed or
malicious URL (missing scheme, //host, or non-http(s) schemes) can create broken links or an
open-redirect-style phishing vector when users click the artifact.
Code

workspaces/x2a/plugins/x2a/src/components/ModuleTable/Artifacts.tsx[R42-49]

+  const url =
+    artifact.type === 'ansible_project'
+      ? artifact.value
+      : buildArtifactUrl(artifact.value, targetRepoUrl, targetRepoBranch);
  return (
    <Link
-      to={buildArtifactUrl(artifact.value, targetRepoUrl, targetRepoBranch)}
+      to={url}
      target="_blank"
Evidence
Frontend bypasses buildArtifactUrl for ansible_project and uses the raw string as the link
target. That string is derived from ${AAP_CONTROLLER_URL} in the job script, which comes from
aapCredentials.url validated only as z.string() (no URL/scheme constraints).

workspaces/x2a/plugins/x2a/src/components/ModuleTable/Artifacts.tsx[30-55]
workspaces/x2a/plugins/x2a/src/components/ModulePage/ArtifactsCard.tsx[113-124]
workspaces/x2a/plugins/x2a-backend/src/router/modules.ts[210-232]
workspaces/x2a/plugins/x2a-backend/src/services/JobResourceBuilder.ts[47-87]
workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[420-427]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`ansible_project` artifacts are now rendered as raw URLs (`artifact.value`) in the UI, but the backend currently accepts AAP `url` as an unconstrained string and propagates it into artifact generation. This can lead to malformed links and enables open-redirect-style phishing if a crafted URL is stored.

### Issue Context
- Backend accepts `aapCredentials.url` from requests and uses it to set `AAP_CONTROLLER_URL`.
- Job script builds the returned artifact URL from `AAP_CONTROLLER_URL`.
- Frontend renders the returned `ansible_project` artifact via `&lt;Link to={artifact.value}&gt;`.

### Fix Focus Areas
- workspaces/x2a/plugins/x2a-backend/src/router/modules.ts[210-232]
- workspaces/x2a/plugins/x2a-backend/src/services/JobResourceBuilder.ts[47-87]
- workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[420-427]
- workspaces/x2a/plugins/x2a/src/components/ModuleTable/Artifacts.tsx[42-55]
- workspaces/x2a/plugins/x2a/src/components/ModulePage/ArtifactsCard.tsx[113-127]

### Implementation notes (non-exhaustive)
- Backend: change zod validation to require a real URL and restrict protocol to http/https (e.g., `z.string().url().refine(u =&gt; new URL(u).protocol in {&quot;http:&quot;,&quot;https:&quot;})`).
- Normalize by trimming trailing slash before persisting/using (or in the job script: `AAP_CONTROLLER_URL=&quot;${AAP_CONTROLLER_URL%/}&quot;`).
- Frontend: for `ansible_project`, compute `href` like:
 - if `value` starts with `http://` or `https://` =&gt; use it
 - else =&gt; fallback to `buildArtifactUrl(value, targetRepoUrl, targetRepoBranch)` (covers older persisted artifacts / malformed values)
 - if invalid =&gt; render text (no link) or render a safe fallback page link.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Spanish i18n mojibake 🐞 Bug ✓ Correctness
Description
The Spanish translations include corrupted accented characters (e.g., "��ltima", "��xito"), so the
UI will display garbled text for common labels. This PR touches the translation set and should fix
the broken strings before merging.
Code

workspaces/x2a/plugins/x2a/src/translations/es.ts[R80-85]

+    'module.lastUpdate': '��ltima actualización',
    'module.notStarted': 'No iniciado',
-    'module.lastPhase': '��ltima fase',
+    'module.lastPhase': '��ltima fase',
    'module.name': 'Nombre',
    'module.status': 'Estado',
    'module.sourcePath': 'Ruta de origen',
Evidence
The current Spanish translation file contains replacement characters ("��") in multiple user-visible
strings, indicating an encoding/contents issue.

workspaces/x2a/plugins/x2a/src/translations/es.ts[74-99]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
Spanish translations contain mojibake (&quot;��&quot;) for accented characters, causing visible UI text corruption.

### Issue Context
The affected strings are common labels (last update, last phase, success status), so the problem is user-facing.

### Fix Focus Areas
- workspaces/x2a/plugins/x2a/src/translations/es.ts[74-99]

### Implementation notes (non-exhaustive)
- Update the specific values:
 - &#x27;module.lastUpdate&#x27;: &#x27;Última actualización&#x27;
 - &#x27;module.lastPhase&#x27;: &#x27;Última fase&#x27;
 - &#x27;module.statuses.success&#x27;: &#x27;Éxito&#x27;
 - &#x27;modulePage.phases.statuses.success&#x27;: &#x27;Éxito&#x27;
- Ensure editor/formatter preserves UTF-8 and no replacement characters remain.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 4, 2026

Comment on lines +42 to 49
const url =
artifact.type === 'ansible_project'
? artifact.value
: buildArtifactUrl(artifact.value, targetRepoUrl, targetRepoBranch);
return (
<Link
to={buildArtifactUrl(artifact.value, targetRepoUrl, targetRepoBranch)}
to={url}
target="_blank"

Choose a reason for hiding this comment

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

Action required

1. Unvalidated aap artifact url 🐞 Bug ⛨ Security

The UI now renders ansible_project using artifact.value directly as a link, while the backend
accepts aapCredentials.url as an arbitrary string and passes it into the job env. A malformed or
malicious URL (missing scheme, //host, or non-http(s) schemes) can create broken links or an
open-redirect-style phishing vector when users click the artifact.
Agent Prompt
### Issue description
`ansible_project` artifacts are now rendered as raw URLs (`artifact.value`) in the UI, but the backend currently accepts AAP `url` as an unconstrained string and propagates it into artifact generation. This can lead to malformed links and enables open-redirect-style phishing if a crafted URL is stored.

### Issue Context
- Backend accepts `aapCredentials.url` from requests and uses it to set `AAP_CONTROLLER_URL`.
- Job script builds the returned artifact URL from `AAP_CONTROLLER_URL`.
- Frontend renders the returned `ansible_project` artifact via `<Link to={artifact.value}>`.

### Fix Focus Areas
- workspaces/x2a/plugins/x2a-backend/src/router/modules.ts[210-232]
- workspaces/x2a/plugins/x2a-backend/src/services/JobResourceBuilder.ts[47-87]
- workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh[420-427]
- workspaces/x2a/plugins/x2a/src/components/ModuleTable/Artifacts.tsx[42-55]
- workspaces/x2a/plugins/x2a/src/components/ModulePage/ArtifactsCard.tsx[113-127]

### Implementation notes (non-exhaustive)
- Backend: change zod validation to require a real URL and restrict protocol to http/https (e.g., `z.string().url().refine(u => new URL(u).protocol in {"http:","https:"})`).
- Normalize by trimming trailing slash before persisting/using (or in the job script: `AAP_CONTROLLER_URL="${AAP_CONTROLLER_URL%/}"`).
- Frontend: for `ansible_project`, compute `href` like:
  - if `value` starts with `http://` or `https://` => use it
  - else => fallback to `buildArtifactUrl(value, targetRepoUrl, targetRepoBranch)` (covers older persisted artifacts / malformed values)
  - if invalid => render text (no link) or render a safe fallback page link.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@mareklibra
Copy link
Member

Can this wait for #2448 ?
It will be easier to resolve merge conflicts in this small PR.

@eloycoto
Copy link
Contributor

eloycoto commented Mar 5, 2026

@mareklibra ok

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.

3 participants