Skip to content

Conversation

@knewbury01
Copy link
Contributor

@knewbury01 knewbury01 commented Dec 10, 2025

What This PR Contributes

QL models and tests for Xml Fragments that are programatically instantiated

Future Works

  • js fragments entirely
  • fragments statically associated to views (declared via <Fragment> tags and no programatic controller association (declarative views)
  • consideration for the way to express whether a fragment is instantiated or not (currently built into getControllerName in XmlFragment, but this could be replaced with a similar mechanism to the placeAt dynamic model in remote flow sources, or possibly inherently in the detection of the fragment itself (ie to say a fragment is only a fragment once it is instantiated - though may be complex when there is no controller)?

@knewbury01 knewbury01 requested a review from mbaluda December 30, 2025 17:42
@data-douser data-douser added enhancement New feature or request javascript Pull requests that update javascript code labels Dec 30, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for modeling XML fragments in SAPUI5 applications to enable XSS vulnerability detection. It introduces the ability to track data flow through programmatically instantiated fragments using both Controller.loadFragment() and Fragment.load() APIs.

Key changes:

  • New Fragment.qll module to model Fragment.load() API calls
  • Extended UI5View.qll with XmlFragment class to handle fragment definitions
  • Added two test cases demonstrating XSS detection through fragments loaded via different methods

Reviewed changes

Copilot reviewed 22 out of 24 changed files in this pull request and generated 9 comments.

File Description
javascript/frameworks/ui5/lib/advanced_security/javascript/frameworks/ui5/Fragment.qll New module defining FragmentLoad class to model sap.ui.core.Fragment.load() API calls and extract configuration parameters
javascript/frameworks/ui5/lib/advanced_security/javascript/frameworks/ui5/UI5View.qll Extended with XmlFragment class (lines 690-777) to model XML fragments, their controllers, sources, and sinks; updated TUI5Control to include fragment.xml files
javascript/frameworks/ui5/test/queries/UI5Xss/xss-xml-fragment/* Test case using Controller.loadFragment() to load a fragment with XSS source and sink
javascript/frameworks/ui5/test/queries/UI5Xss/xss-xml-fragment-load/* Test case using Fragment.load() with explicit controller parameter to load a fragment with XSS source and sink
Files not reviewed (2)
  • javascript/frameworks/ui5/test/queries/UI5Xss/xss-xml-fragment-load/package-lock.json: Language not supported
  • javascript/frameworks/ui5/test/queries/UI5Xss/xss-xml-fragment/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"sap/ui/model/json/JSONModel",
"sap/ui/core/Fragment"
], function (Controller, JSONModel, Fragment) {
"use strict"
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

Missing semicolon after the "use strict" directive. This should be "use strict"; for consistency and to avoid potential issues with ASI (Automatic Semicolon Insertion).

Suggested change
"use strict"
"use strict";

Copilot uses AI. Check for mistakes.
oView.placeAt("content");
});

}); No newline at end of file
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

Missing semicolon after the closing parenthesis of the function call. The statement should end with a semicolon for consistency with JavaScript best practices.

Suggested change
});
});

Copilot uses AI. Check for mistakes.
import advanced_security.javascript.frameworks.ui5.UI5

/**
* Gets a reference to the Fragment module import.
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

The documentation comment says "Gets a reference to the Fragment module import" but the class name is FragmentLoad, which represents a Fragment.load() call rather than just a module import. The comment should be updated to clarify that this class models calls to Fragment.load() or Controller.loadFragment().

Suggested change
* Gets a reference to the Fragment module import.
* Models calls to sap.ui.core.Fragment.load() or Controller.loadFragment().

Copilot uses AI. Check for mistakes.
Comment on lines +189 to +198
/**
* A UI5 Fragment that might include XSS sources and sinks in standard controls.
*/
abstract class UI5Fragment extends File {
abstract UI5Control getControl();

abstract UI5BindingPath getASource();

abstract UI5BindingPath getAnHtmlISink();
}
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

The abstract class UI5Fragment is defined but never used. The XmlFragment class extends UI5View instead of UI5Fragment. Either remove this unused abstract class or update XmlFragment to extend UI5Fragment if that was the original intent. If UI5Fragment is intended for future use (as mentioned in the PR description for JS fragments), consider adding a comment to clarify this.

Copilot uses AI. Check for mistakes.
"sap/ui/core/mvc/Controller",
"sap/ui/model/json/JSONModel"
], function (Controller, JSONModel) {
"use strict"
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

Missing semicolon after the "use strict" directive. This should be "use strict"; for consistency and to avoid potential issues with ASI (Automatic Semicolon Insertion).

Suggested change
"use strict"
"use strict";

Copilot uses AI. Check for mistakes.
}.bind(this));
}
});
}) No newline at end of file
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

Missing semicolon after the closing parenthesis of the function call. The statement should end with a semicolon for consistency with JavaScript best practices.

Suggested change
})
});

Copilot uses AI. Check for mistakes.
}.bind(this));
}
});
}) No newline at end of file
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

Missing semicolon after the closing parenthesis of the function call. The statement should end with a semicolon for consistency with JavaScript best practices.

Suggested change
})
});

Copilot uses AI. Check for mistakes.
oView.placeAt("content");
});

}); No newline at end of file
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

Missing semicolon after the closing parenthesis of the function call. The statement should end with a semicolon for consistency with JavaScript best practices.

Suggested change
});
});
;

Copilot uses AI. Check for mistakes.
or
exists(RequiredObject requiredModule, SapDefineModule sapModule |
this = requiredModule.asSourceNode().getAMemberCall("load") and
//ensure it is an sap module define
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

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

Inconsistent comment style. This line uses a C++-style comment (//) while the rest of the file uses QLDoc comments (/** ... */). Consider using a QLDoc comment or block comment for consistency.

Suggested change
//ensure it is an sap module define
/* ensure it is an sap module define */

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request javascript Pull requests that update javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants