Publish error after upgrading to 15.1

After upgrading to 15.1 and recompiling the post publish dll, we get the following error upon publish

Failed with exception System.IO.FileNotFoundException: The URI 'file:///.xxxxfilepath' is not trusted

I checked and the file exists, is there additional config to trust the Publish folder?

emoji
  • Hi Akheil,

    To continuously earn our badges on SAST, DAST and SCA like you can see on https://www.veracode.com/verified/directory/rws-group we need to act on scan results of Static Code Analysis (SCA) and the likes.

    This requries us to rewrite our code to make it more secure, however in turn it could also require a tweak in custom code.

    I'm going to asume that

    1. Your .xxxxfilepath was probalby an xml/dita file and not a system, DLL or catalog file.
    2. The throwing code is something like "Trisoft.Utilities.Common.XmlOASISCatalog.ValidateUri" as the full stack trace is missing in this thread

    Use following code to load a file:

    using (FileStream stream = File.OpenRead(_ditaMapPath))
    using (XmlReader reader = XmlReader.Create(stream, settings))
    {
        ...
    }

    When using XmlReader.Create(String inputUri, ...), inputUri is passed to the XmlResolver to convert the path.
    Because the XmlResolverUsingCatalog is used as XmlResolver, only paths defined in the catalog are allowed.

    It's safer to use XmlReader.Create(Stream input, ...).
    When File.OpenRead(topic) is used, only local files can be loaded (URLs are not possible),
    and when XmlReader(Stream input, ...) is used, the file path is not passed to the XmlResolver, which prevents it from checking if the file path exists in the catalog.

    If my assumptions are off, please share some sample code and full stack traces. 

    Best wishes,
    Dave

    emoji
  •   All the recent coding work we have been using XDocument looks like all those custom plugins are working well.

    Only the plugins which has XMLDocument instead of XDocument were throwing this error. So I suggested them to use XDocument instead which is working.

    The most commonly use PS plugin InfoshareRenameFiles has same issue as well. We will need to rewrite those XMLDocument calls there as well.

    Screenshot of code comparing XMLDocument and XDocument implementations. Left side shows XMLDocument with XmlReader, right side shows XDocument with Descendants method.

    emoji


    Generated Image Alt-Text
    [edited by: RWS Community AI at 1:55 PM (GMT 1) on 12 Sep 2024]