If the source code is published, hackers can surly read it and find ways into the software causing security risks?
Publishing the source code actually improves the security of software. Companies which produce software commercially only have a finite number of developers working on a software product. Although reviewing and testing a software product before release is common practise, that company can only provide a certain number of resources even in the largest software companies. Open source code is published so that everyone around the world can see it allowing the tens of thousands of people who participate in these communities to test, review and contribute. Security holes are found much quicker in open source software because there are many more eyes looking at the problem than could ever be possible in a commercial organisation. Even when problems are found, these same people can write a patch and send it to the community for review which explains why problems in open source software are fixed much quicker than their commercial equivalent.