XML Parser triggers AV Alert

为君一笑 提交于 2019-12-11 07:03:01

问题


I am developing an Android app which reads current currency exchange rates from an online XML file and parses it via w3c DOM. The file is located on my AWS S3 storage.

The parser works fine and I get all rates as I want them but my Anti-Virus app (avast!) keeps flagging my app as Malware (Android:Agent-YI[Trj]). When I comment the code out and the method I use just returns true the AV keeps quiet and thus I narrowed it down to the code below.

Does somebody know why the AV doesn't accept my code? The only permissions of the apps are:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>

The parser code:

public static boolean fetchCurrencyRates(String in)
{
    boolean success = true;

    HashMap<String, Double> onlineRates = new HashMap<String, Double>();

    try
    {
        Document xmlRates = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(in);
        xmlRates.getDocumentElement().normalize();

        NodeList xmlItems = xmlRates.getElementsByTagName("item");

        for(int i = 0; i < xmlItems.getLength(); i++)
        {
            Node n = xmlItems.item(i);

            if(n != null && n.getNodeType() == Node.ELEMENT_NODE)
            {
                Element currency = (Element) n;

                String code = currency.getElementsByTagName("title").item(0)
                                                                    .getTextContent()
                                                                    .substring(0, 3);

                String rate = currency.getElementsByTagName("description").item(0)
                                                                          .getTextContent()
                                                                          .split(" ")[3];

                Log.i("DEV", code + ": " + rate);
                onlineRates.put(code, Double.parseDouble(rate.replaceAll(",", "")));
            }
        }
    }
    catch(Exception e)
    {
        Log.e("DEV", e.getMessage();
        success = false;
    }

    return success && !onlineRates.isEmpty();
}

I also tried to use XmlPullParser as recommended by the Android Documentation but ran into the same problem.


回答1:


I figured out why the AV didn't like my code. Apparently the XML parsing did not cause the problem after all...

In order to load the data I used an AsyncTask and did not implement any visual feedback (ProgessDialog) yet. This alone was enough for the AV alert.



来源:https://stackoverflow.com/questions/16890512/xml-parser-triggers-av-alert

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!