It is far from clear, which is why I am pointing out that some folklorists think it does not come from folk tradition.
Regarding Basile, see long argument starting from page 75 in this book: http://www.academia.edu/19594654/A_FAIRY_TALE_NEW_HISTORY_Ru...
Chapter 4:
The Two Inventors of Fairy Tale Tradition
Giambattista Basile (1634–1636) and Giovan Francesco Straparola (1551, 1553)
> The stories in the Pentamerone were collected by Basile and published posthumously
It's clear, once again, that while he may have embellished them for publication, he was not creating them out of whole cloth, but collecting them from folk tales in his area.